]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - image.c
fixed menu player colormapping
[xonotic/darkplaces.git] / image.c
diff --git a/image.c b/image.c
index d388637b14d2edb818a16de76525dada6c6f6ee3..caa087e056efb42a83555e6985edb9539a6ecf7c 100644 (file)
--- a/image.c
+++ b/image.c
@@ -453,6 +453,52 @@ qbyte *LoadLMP (qbyte *f, int matchwidth, int matchheight)
        return image_rgba;
 }
 
+/*
+============
+LoadLMP
+============
+*/
+qbyte *LoadLMPAs8Bit (qbyte *f, int matchwidth, int matchheight)
+{
+       qbyte *image_8bit;
+       int width, height;
+
+       if (loadsize < 9)
+       {
+               Con_Printf("LoadLMPAs8Bit: invalid LMP file\n");
+               return NULL;
+       }
+
+       // parse the very complicated header *chuckle*
+       width = f[0] + f[1] * 256 + f[2] * 65536 + f[3] * 16777216;
+       height = f[4] + f[5] * 256 + f[6] * 65536 + f[7] * 16777216;
+       if ((unsigned) width > 4096 || (unsigned) height > 4096)
+       {
+               Con_Printf("LoadLMPAs8Bit: invalid size\n");
+               return NULL;
+       }
+       if ((matchwidth && width != matchwidth) || (matchheight && height != matchheight))
+               return NULL;
+
+       if (loadsize < 8 + width * height)
+       {
+               Con_Printf("LoadLMPAs8Bit: invalid LMP file\n");
+               return NULL;
+       }
+
+       image_width = width;
+       image_height = height;
+
+       image_8bit = Mem_Alloc(tempmempool, image_width * image_height);
+       if (!image_8bit)
+       {
+               Con_Printf("LoadLMPAs8Bit: not enough memory for %i by %i image\n", image_width, image_height);
+               return NULL;
+       }
+       memcpy(image_8bit, f + 8, image_width * image_height);
+       return image_8bit;
+}
+
 void Image_StripImageExtension (char *in, char *out)
 {
        char *end, *temp;