--- xzgv-0.9/src/backend.c 2007-09-09 02:37:14.000000000 +0200 +++ xzgv-0.9.new/src/backend.c 2009-01-09 17:26:29.000000000 +0100 @@ -91,6 +91,8 @@ image->rgb=gdk_pixbuf_get_pixels(BACKEND_IMAGE(image)); image->w=gdk_pixbuf_get_width(BACKEND_IMAGE(image)); image->h=gdk_pixbuf_get_height(BACKEND_IMAGE(image)); +image->stride=gdk_pixbuf_get_rowstride(BACKEND_IMAGE(image)); +image->has_alpha=gdk_pixbuf_get_has_alpha(BACKEND_IMAGE(image)); } --- xzgv-0.9/src/backend.h 2007-09-09 02:49:12.000000000 +0200 +++ xzgv-0.9.new/src/backend.h 2009-01-09 17:25:47.000000000 +0100 @@ -8,6 +8,8 @@ { unsigned char *rgb; /* raw RGB data */ int w,h; /* width/height */ + int stride; + int has_alpha; void *backend_image; /* backend's image type (opaque) */ void *backend_ext; /* any extra info needed by backend (opaque) */ }; --- xzgv-0.9/src/resizepic.c 2007-08-11 20:08:41.000000000 +0200 +++ xzgv-0.9.new/src/resizepic.c 2009-01-09 17:15:28.000000000 +0100 @@ -22,7 +22,7 @@ * which should then be reduced more nicely for the thumbnail. */ unsigned char *nasty_resizepic(unsigned char *theimage, - int width,int height,int *sw_ask,int *sh_ask) + int width,int height,int stride, int *sw_ask,int *sh_ask) { int x,y,yp,yw,sw,sh,lastyp,scrnwide,scrnhigh; unsigned char *rline,*outimage; @@ -60,9 +60,9 @@ rline=outimage+yp*sw*3; if(yp!=lastyp) { - yw=y*width; - for(x=0;xw!=origw || origpic->h!=origh) allow_crunch=0; +if (origpic->has_alpha) + /* Bummer we've got RGBA pixel data but all the other code expects packed + RGB data, so convert it. */ + for (y = 0; y < origh; y++) + for (x = 0; x < origw; x++) + { + origpic->rgb[y * origpic->stride + x * 3] = + origpic->rgb[y * origpic->stride + x * 4]; + origpic->rgb[y * origpic->stride + x * 3 + 1] = + origpic->rgb[y * origpic->stride + x * 4 + 1]; + origpic->rgb[y * origpic->stride + x * 3 + 2] = + origpic->rgb[y * origpic->stride + x * 4 + 2]; + } + /* resize */ w=80; h=60; -smallpic=resizepic(origpic->rgb, - width=origpic->w,height=origpic->h,&w,&h, +smallpic=resizepic(origpic->rgb, origw, origh, origpic->stride, &w,&h, allow_crunch); backend_image_destroy(origpic); /* finished with this */