X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fpcx.c;h=47a11d462fec86888cdb14b7cd7e39c99a3708ab;hb=ad15815ec04f42779d0717a6d291f93b8e847d39;hp=7756b240f1831041170475fd12a52277043d3ee1;hpb=0548cd8fd0353c19608df8a7079fc2c39cc4ce27;p=rocksndiamonds.git diff --git a/src/libgame/pcx.c b/src/libgame/pcx.c index 7756b240..47a11d46 100644 --- a/src/libgame/pcx.c +++ b/src/libgame/pcx.c @@ -19,7 +19,7 @@ #include "misc.h" -#define PCX_DEBUG FALSE +#define PCX_DEBUG 0 #define PCX_MAGIC 0x0a /* first byte in a PCX image file */ #define PCX_SUPPORTED_VERSION 5 /* last acceptable version number */ @@ -169,6 +169,9 @@ static boolean PCX_ReadBitmap(FILE *file, struct PCX_Header *pcx, Image *image) { byte bit = (value >> j) & 1; + if (i * 8 + j >= width) /* skip padding bits */ + continue; + bitmap_ptr[x++] |= bit << plane; } } @@ -332,6 +335,7 @@ Image *Read_PCX_to_Image(char *filename) #if PCX_DEBUG if (options.verbose) { + printf("\n"); printf("%s is a %dx%d PC Paintbrush image\n", filename, width, height); printf("depth: %d\n", depth); printf("bits_per_pixel: %d\n", pcx.bits_per_pixel); @@ -371,7 +375,6 @@ Image *Read_PCX_to_Image(char *filename) if (pcx_depth == 8) { /* determine number of used colormap entries for 8-bit PCX images */ - image->rgb.used = 0; for (i=0; irgb.color_used[i]) image->rgb.used++; @@ -379,7 +382,7 @@ Image *Read_PCX_to_Image(char *filename) #if PCX_DEBUG if (options.verbose) - printf("Read_PCX_to_Image: %d colors found\n", image->rgb.used); + printf("Read_PCX_to_Image: %d colors in colormap\n", image->rgb.used); #endif return image;