X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fpcx.c;h=8bf4d6c1424a2ca62fc61a8ccbfe68ef6ade2111;hb=37a06df577bbfd00f4b361f92cacb0d97036ba93;hp=c7b308b0900a4d56644f73823e7248c173131fb3;hpb=76510834f382bc82548e72c8e7f6f7672c9484dc;p=rocksndiamonds.git diff --git a/src/libgame/pcx.c b/src/libgame/pcx.c index c7b308b0..8bf4d6c1 100644 --- a/src/libgame/pcx.c +++ b/src/libgame/pcx.c @@ -53,52 +53,6 @@ struct PCX_Header /* global PCX error value */ int errno_pcx = PCX_Success; -#if 0 -static byte *PCX_ReadBitmap(Image *image, byte *buffer_ptr, byte *buffer_last) -{ - /* Run Length Encoding: If the two high bits are set, - * then the low 6 bits contain a repeat count, and the byte to - * repeat is the next byte in the file. If the two high bits are - * not set, then this is the byte to write. - */ - - unsigned int bytes_per_pixel = (image->depth + 7) / 8; - register byte *bitmap_ptr, *bitmap_last; - register byte value, count; - - bitmap_ptr = image->data; - bitmap_last = bitmap_ptr + (image->width * image->height * bytes_per_pixel); - - while (bitmap_ptr < bitmap_last && buffer_ptr < buffer_last) - { - value = *buffer_ptr++; - - if ((value & 0xc0) == 0xc0) /* this is a repeat count byte */ - { - count = value & 0x3f; /* extract repeat count from byte */ - value = *buffer_ptr++; /* next byte is value to repeat */ - - for (; count && bitmap_ptr < bitmap_last; count--) - *bitmap_ptr++ = value; - - if (count) /* repeat count spans end of bitmap */ - return NULL; - } - else - *bitmap_ptr++ = value; - - image->rgb.color_used[value] = TRUE; - } - - /* check if end of buffer was reached before end of bitmap */ - if (bitmap_ptr < bitmap_last) - return NULL; - - /* return current buffer position for next decoding function */ - return buffer_ptr; -} -#endif - static boolean PCX_ReadBitmap(FILE *file, struct PCX_Header *pcx, Image *image) { int width = image->width; @@ -167,12 +121,11 @@ static boolean PCX_ReadBitmap(FILE *file, struct PCX_Header *pcx, Image *image) for (j = 7; j >= 0; j--) { - byte bit; + byte bit = (value >> j) & 1; if (i * 8 + j >= width) /* skip padding bits */ continue; - bit = (value >> j) & 1; bitmap_ptr[x++] |= bit << plane; } } @@ -204,35 +157,6 @@ static boolean PCX_ReadBitmap(FILE *file, struct PCX_Header *pcx, Image *image) return TRUE; } -#if 0 -static byte *PCX_ReadColormap(Image *image,byte *buffer_ptr, byte *buffer_last) -{ - int i, magic; - - /* read colormap magic byte */ - magic = *buffer_ptr++; - - /* check magic colormap header byte */ - if (magic != PCX_256COLORS_MAGIC) - return NULL; - - /* check if enough bytes left for a complete colormap */ - if (buffer_ptr + PCX_COLORMAP_SIZE > buffer_last) - return NULL; - - /* read 256 colors from PCX colormap */ - for (i=0; irgb.red[i] = *buffer_ptr++ << 8; - image->rgb.green[i] = *buffer_ptr++ << 8; - image->rgb.blue[i] = *buffer_ptr++ << 8; - } - - /* return current buffer position for next decoding function */ - return buffer_ptr; -} -#endif - static boolean PCX_ReadColormap(FILE *file,struct PCX_Header *pcx,Image *image) { int pcx_depth = pcx->bits_per_pixel * pcx->color_planes; @@ -257,7 +181,7 @@ static boolean PCX_ReadColormap(FILE *file,struct PCX_Header *pcx,Image *image) while (value != PCX_256COLORS_MAGIC); /* read 256 colors from PCX colormap */ - for(i = 0; i < PCX_MAXCOLORS; i++) + for (i = 0; i < PCX_MAXCOLORS; i++) { image->rgb.red[i] = (byte)fgetc(file) << 8; image->rgb.green[i] = (byte)fgetc(file) << 8; @@ -266,7 +190,7 @@ static boolean PCX_ReadColormap(FILE *file,struct PCX_Header *pcx,Image *image) } else { - for(i = 0; i < num_colors; i++) + for (i = 0; i < num_colors; i++) { image->rgb.red[i] = pcx->palette[i][0] << 8; image->rgb.green[i] = pcx->palette[i][1] << 8; @@ -376,7 +300,7 @@ Image *Read_PCX_to_Image(char *filename) if (pcx_depth == 8) { /* determine number of used colormap entries for 8-bit PCX images */ - for (i=0; irgb.color_used[i]) image->rgb.used++; }