X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fimage.c;h=498c1c0bfb3a2c034cda879797ac2401e9cb54d8;hb=61c3da024802ecc0268bab42d7499fc0346e4fd3;hp=85a73a54f2a29322acb80ce9e4b9fab4f779ebd7;hpb=db0cf963a41d958dc11ee1d3cfb2b1f88cba7f76;p=rocksndiamonds.git diff --git a/src/libgame/image.c b/src/libgame/image.c index 85a73a54..498c1c0b 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -64,28 +64,28 @@ void freeImage(Image *image) note: the internal format is big endian */ #define memory_to_value(ptr, len) ( \ -(len) == 1 ? (unsigned long)( *( (byte *)(ptr)) ) : \ -(len) == 2 ? (unsigned long)(((unsigned long)(*( (byte *)(ptr)) ))<< 8) \ - + ( *(((byte *)(ptr))+1) ) : \ -(len) == 3 ? (unsigned long)(((unsigned long)(*( (byte *)(ptr)) ))<<16) \ - + (((unsigned long)(*(((byte *)(ptr))+1)))<< 8) \ - + ( *(((byte *)(ptr))+2) ) : \ - (unsigned long)(((unsigned long)(*( (byte *)(ptr)) ))<<24) \ - + (((unsigned long)(*(((byte *)(ptr))+1)))<<16) \ - + (((unsigned long)(*(((byte *)(ptr))+2)))<< 8) \ - + ( *(((byte *)(ptr))+3) ) ) +(len) == 1 ? (unsigned int)( *( (byte *)(ptr)) ) : \ +(len) == 2 ? (unsigned int)(((unsigned int)(*( (byte *)(ptr)) ))<< 8) \ + + ( *(((byte *)(ptr))+1) ) : \ +(len) == 3 ? (unsigned int)(((unsigned int)(*( (byte *)(ptr)) ))<<16) \ + + (((unsigned int)(*(((byte *)(ptr))+1)))<< 8) \ + + ( *(((byte *)(ptr))+2) ) : \ + (unsigned int)(((unsigned int)(*( (byte *)(ptr)) ))<<24) \ + + (((unsigned int)(*(((byte *)(ptr))+1)))<<16) \ + + (((unsigned int)(*(((byte *)(ptr))+2)))<< 8) \ + + ( *(((byte *)(ptr))+3) ) ) #define value_to_memory(value, ptr, len) ( \ (len) == 1 ? (*( (byte *)(ptr) ) = ( value ) ) : \ -(len) == 2 ? (*( (byte *)(ptr) ) = (((unsigned long)(value))>> 8), \ +(len) == 2 ? (*( (byte *)(ptr) ) = (((unsigned int)(value))>> 8), \ *(((byte *)(ptr))+1) = ( value ) ) : \ -(len) == 3 ? (*( (byte *)(ptr) ) = (((unsigned long)(value))>>16), \ - *(((byte *)(ptr))+1) = (((unsigned long)(value))>> 8), \ +(len) == 3 ? (*( (byte *)(ptr) ) = (((unsigned int)(value))>>16), \ + *(((byte *)(ptr))+1) = (((unsigned int)(value))>> 8), \ *(((byte *)(ptr))+2) = ( value ) ) : \ - (*( (byte *)(ptr) ) = (((unsigned long)(value))>>24), \ - *(((byte *)(ptr))+1) = (((unsigned long)(value))>>16), \ - *(((byte *)(ptr))+2) = (((unsigned long)(value))>> 8), \ + (*( (byte *)(ptr) ) = (((unsigned int)(value))>>24), \ + *(((byte *)(ptr))+1) = (((unsigned int)(value))>>16), \ + *(((byte *)(ptr))+2) = (((unsigned int)(value))>> 8), \ *(((byte *)(ptr))+3) = ( value ) )) static Pixmap Image_to_Mask(Image *image, Display *display, Window window) @@ -649,7 +649,11 @@ void ZoomPixmap(Display *display, GC gc, Pixmap src_pixmap, Pixmap dst_pixmap, if (scale_down) { +#if 1 + zoom_factor = MIN(src_width / dst_width, src_height / dst_height); +#else zoom_factor = src_width / dst_width; +#endif /* adjust source image size to integer multiple of destination size */ src_width = dst_width * zoom_factor; @@ -657,7 +661,11 @@ void ZoomPixmap(Display *display, GC gc, Pixmap src_pixmap, Pixmap dst_pixmap, } else { +#if 1 + zoom_factor = MIN(dst_width / src_width, dst_height / src_height); +#else zoom_factor = dst_width / src_width; +#endif /* no adjustment needed when scaling up (some pixels may be left blank) */ }