From 7b1be917efb26279d3446b776cdea70afbd2dbc8 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 6 Jun 2006 03:37:34 +0000 Subject: Applied patch #1501134 (bzr r1163) --- src/trace/siox.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/trace/siox.cpp') diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp index 955446b42..752a14460 100644 --- a/src/trace/siox.cpp +++ b/src/trace/siox.cpp @@ -574,16 +574,19 @@ SioxImage::SioxImage(GdkPixbuf *buf) */ GdkPixbuf *SioxImage::getGdkPixbuf() { + bool has_alpha = true; + int n_channels = has_alpha ? 4 : 3; + guchar *pixdata = (guchar *) - malloc(sizeof(guchar) * width * height * 3); + malloc(sizeof(guchar) * width * height * n_channels); if (!pixdata) return NULL; - int n_channels = 3; - int rowstride = width * 3; + int rowstride = width * n_channels; - GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, - 0, 8, width, height, + GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, + GDK_COLORSPACE_RGB, + has_alpha, 8, width, height, rowstride, NULL, NULL); //### Fill in the cells with RGB values @@ -594,9 +597,13 @@ GdkPixbuf *SioxImage::getGdkPixbuf() for (unsigned x=0 ; x < width ; x++) { unsigned int rgb = getPixel(x, y); - p[0] = (rgb >> 16) & 0xff; - p[1] = (rgb >> 8) & 0xff; - p[2] = (rgb ) & 0xff; + p[0] = (rgb >> 16) & 0xff;//r + p[1] = (rgb >> 8) & 0xff;//g + p[2] = (rgb ) & 0xff;//b + if ( n_channels > 3 ) + { + p[3] = (rgb >> 24) & 0xff;//a + } p += n_channels; } row += rowstride; -- cgit v1.2.3