#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 */
{
byte bit = (value >> j) & 1;
+ if (i * 8 + j >= width) /* skip padding bits */
+ continue;
+
bitmap_ptr[x++] |= bit << plane;
}
}
return NULL;
/* read 256 colors from PCX colormap */
- for (i=0; i<PCX_MAXCOLORS; i++)
+ for (i = 0; i < PCX_MAXCOLORS; i++)
{
image->rgb.red[i] = *buffer_ptr++ << 8;
image->rgb.green[i] = *buffer_ptr++ << 8;
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;
}
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;
#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);
if (pcx_depth == 8)
{
/* determine number of used colormap entries for 8-bit PCX images */
- image->rgb.used = 0;
- for (i=0; i<PCX_MAXCOLORS; i++)
+ for (i = 0; i < PCX_MAXCOLORS; i++)
if (image->rgb.color_used[i])
image->rgb.used++;
}
#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;