- return image_rgba;
-}
-
-/*
-============
-LoadLMP
-============
-*/
-unsigned char *LoadLMP (const unsigned char *f, int filesize, int matchwidth, int matchheight, qboolean loadAs8Bit)
-{
- unsigned char *image_buffer;
-
- if (filesize < 9)
- {
- Con_Print("LoadLMP: invalid LMP file\n");
- return NULL;
- }
-
- // parse the very complicated header *chuckle*
- image_width = BuffLittleLong(f);
- image_height = BuffLittleLong(f + 4);
- if (image_width > 4096 || image_height > 4096 || image_width <= 0 || image_height <= 0)
- {
- Con_Printf("LoadLMP: invalid size %ix%i\n", image_width, image_height);
- return NULL;
- }
- if ((matchwidth && image_width != matchwidth) || (matchheight && image_height != matchheight))
- return NULL;
-
- if (filesize < (8 + image_width * image_height))
- {
- Con_Print("LoadLMP: invalid LMP file\n");
- return NULL;
- }
-
- if (loadAs8Bit)
- {
- image_buffer = (unsigned char *)Mem_Alloc(tempmempool, image_width * image_height);
- memcpy(image_buffer, f + 8, image_width * image_height);
- }
- else
- {
- image_buffer = (unsigned char *)Mem_Alloc(tempmempool, image_width * image_height * 4);
- Image_Copy8bitRGBA(f + 8, image_buffer, image_width * image_height, palette_transparent);
- }