From 33c74e3076792e4bc62a5f550c8773723fb8dbc7 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 22 Aug 2004 07:22:39 +0000 Subject: [PATCH] Fix a mixup in the handling of dest_channels. (#111922, Christophe Sun Aug 22 03:20:56 2004 Matthias Clasen * pixops/pixops.c (pixops_scale_nearest): Fix a mixup in the handling of dest_channels. (#111922, Christophe Fergeau) --- gdk-pixbuf/ChangeLog | 5 +++++ gdk-pixbuf/pixops/pixops.c | 37 ++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 074838f5a1..7afc519bc5 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,8 @@ +Sun Aug 22 03:20:56 2004 Matthias Clasen + + * pixops/pixops.c (pixops_scale_nearest): Fix a mixup in the handling + of dest_channels. (#111922, Christophe Fergeau) + Fri Aug 20 11:59:10 2004 Owen Taylor * io-bmp.c: Fix infinite loop that can occur for bad diff --git a/gdk-pixbuf/pixops/pixops.c b/gdk-pixbuf/pixops/pixops.c index 081191cd5d..e263c13d16 100644 --- a/gdk-pixbuf/pixops/pixops.c +++ b/gdk-pixbuf/pixops/pixops.c @@ -78,32 +78,32 @@ pixops_scale_nearest (guchar *dest_buf, int xmax, xstart, xstop, x_pos, y_pos; const guchar *p; -#define INNER_LOOP(SRC_CHANNELS,DEST_CHANNELS,ASSIGN_PIXEL) \ +#define INNER_LOOP(SRC_CHANNELS,DEST_CHANNELS,ASSIGN_PIXEL) \ xmax = x + (render_x1 - render_x0) * x_step; \ xstart = MIN (0, xmax); \ xstop = MIN (src_width << SCALE_SHIFT, xmax); \ p = src + (CLAMP (x, xstart, xstop) >> SCALE_SHIFT) * SRC_CHANNELS; \ while (x < xstart) \ - { \ - ASSIGN_PIXEL; \ - dest += DEST_CHANNELS; \ - x += x_step; \ + { \ + ASSIGN_PIXEL; \ + dest += DEST_CHANNELS; \ + x += x_step; \ } \ while (x < xstop) \ - { \ - p = src + (x >> SCALE_SHIFT) * SRC_CHANNELS; \ - ASSIGN_PIXEL; \ - dest += DEST_CHANNELS; \ - x += x_step; \ - } \ + { \ + p = src + (x >> SCALE_SHIFT) * SRC_CHANNELS; \ + ASSIGN_PIXEL; \ + dest += DEST_CHANNELS; \ + x += x_step; \ + } \ x_pos = x >> SCALE_SHIFT; \ p = src + CLAMP (x_pos, 0, src_width - 1) * SRC_CHANNELS; \ while (x < xmax) \ { \ - ASSIGN_PIXEL; \ - dest += DEST_CHANNELS; \ - x += x_step; \ - } + ASSIGN_PIXEL; \ + dest += DEST_CHANNELS; \ + x += x_step; \ + } for (i = 0; i < (render_y1 - render_y0); i++) { @@ -124,18 +124,18 @@ pixops_scale_nearest (guchar *dest_buf, } else { - INNER_LOOP (3, 4, dest[0]=p[0];dest[1]=p[1];dest[2]=p[2]); + INNER_LOOP (3, 4, dest[0]=p[0];dest[1]=p[1];dest[2]=p[2];dest[3]=0xff); } } else if (src_channels == 4) { if (dest_channels == 3) { - INNER_LOOP (4, 3, dest[0]=p[0];dest[1]=p[1];dest[2]=p[2];dest[3]=0xff); + INNER_LOOP (4, 3, dest[0]=p[0];dest[1]=p[1];dest[2]=p[2]); } else { - gint32 *p32; + guint32 *p32; INNER_LOOP(4, 4, p32=(guint32*)dest;*p32=*((guint32*)p)); } } @@ -169,7 +169,6 @@ pixops_composite_nearest (guchar *dest_buf, const guchar *p; unsigned int a0; - for (i = 0; i < (render_y1 - render_y0); i++) { const guchar *src;