#include "image.h"
#include "misc.h"
+#define PCX_DEBUG FALSE
+
#define PCX_MAGIC 0x0a /* first byte in a PCX image file */
#define PCX_LAST_VERSION 5 /* last acceptable version number */
#define PCX_ENCODING 1 /* PCX encoding method */
{
/* PCX file is too short to contain a valid PCX header */
fclose(file);
+
errno_pcx = PCX_FileInvalid;
return NULL;
}
width < 0 || height < 0)
{
free(file_buffer);
+
errno_pcx = PCX_FileInvalid;
return NULL;
}
+#if PCX_DEBUG
if (options.verbose)
{
printf("%s is a %dx%d PC Paintbrush image with %d bitplanes\n",
- filename, pcx.xmax, pcx.ymax,
+ filename, width, height,
pcx.color_planes);
printf("depth: %d\n", pcx.bits_per_pixel);
printf("color_planes: %d\n", pcx.color_planes);
(pcx.palette_type == 1 ? "color" :
pcx.palette_type == 2 ? "grayscale" : "undefined"));
}
+#endif
/* allocate new image structure */
image = newImage(width, height, depth);
{
free(file_buffer);
freeImage(image);
+
errno_pcx = PCX_FileInvalid;
return NULL;
}
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);
+#endif
return image;
}