int zoom_factor = src_width / dst_width; /* currently very limited! */
int row_skip, col_skip;
+ /* adjust source image size to integer multiple of destination image size */
+ src_width = dst_width * zoom_factor;
+ src_height = dst_height * zoom_factor;
+
/* copy source pixmap to temporary image */
- src_ximage = XGetImage(display, src_pixmap, 0, 0,
- src_width, src_height, AllPlanes, ZPixmap);
+ src_ximage = XGetImage(display, src_pixmap, 0, 0, src_width, src_height,
+ AllPlanes, ZPixmap);
bits_per_pixel = src_ximage->bits_per_pixel;
bytes_per_pixel = (bits_per_pixel + 7) / 8;
/* scale image down by scaling factor 'zoom_factor' */
for (y=0; y < src_height; y += zoom_factor, src_ptr += row_skip)
for (x=0; x < src_width; x += zoom_factor, src_ptr += col_skip)
- for (i=0; i<bytes_per_pixel; i++)
+ for (i=0; i < bytes_per_pixel; i++)
*dst_ptr++ = *src_ptr++;
/* copy scaled image to destination pixmap */
XPutImage(display, dst_pixmap, gc, dst_ximage, 0, 0, 0, 0,
- MIN(src_width, dst_width), MIN(src_height, dst_height));
+ dst_width, dst_height);
/* free temporary images */
XDestroyImage(src_ximage);
#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 */
for (j = 7; j >= 0; j--)
{
- byte bit = (value >> j) & 1;
+ byte bit;
+ if (i * 8 + j >= width) /* skip padding bits */
+ continue;
+
+ bit = (value >> j) & 1;
bitmap_ptr[x++] |= bit << plane;
}
}
#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++)
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;
src_height = src_bitmap->height;
tmp_width = src_width;
- tmp_height = src_height + src_height / 2;
+ tmp_height = src_height + (src_height + 1) / 2; /* prevent odd height */
tmp_bitmap = CreateBitmap(tmp_width, tmp_height, DEFAULT_DEPTH);
FreeBitmap(tmp_bitmap_8);
#if defined(TARGET_SDL)
+ /* !!! what about the old src_bitmap->surface ??? FIX ME !!! */
src_bitmap->surface = tmp_bitmap->surface;
tmp_bitmap->surface = NULL;
#else
+ /* !!! see above !!! */
src_bitmap->drawable = tmp_bitmap->drawable;
tmp_bitmap->drawable = None;
#endif