$NetBSD: patch-ab,v 1.6 2009/01/29 17:57:55 shattered Exp $ Avoid using ARGB visuals. From http://bugs.debian.org/457252. --- src/main.c.orig 2007-12-18 13:55:59.000000000 +0100 +++ src/main.c 2008-05-20 15:23:15.000000000 +0200 @@ -38,6 +38,7 @@ #include #include #include /* needed for iconify stuff */ +#include /* http://bugs.debian.org/457252 */ #include /* ditto */ #include "backend.h" @@ -105,7 +106,7 @@ GtkWidget *mainwin; -gint xvpic_pal[256]; /* palette for thumbnails */ +guint8 xvpic_pal[256][3]; /* palette for thumbnails */ /* image & rendered pixmap for currently-loaded image */ xzgv_image *theimage=NULL; @@ -2514,77 +2515,92 @@ */ void find_xvpic_cols(void) { -GdkColor col; -int r,g,b; -int n; - -for(n=0,r=0;r<8;r++) - for(g=0;g<8;g++) /* colours are 3:3:2 */ - for(b=0;b<4;b++,n++) - { - col.red=r*0xffff/7; col.green=g*0xffff/7; col.blue=b*0xffff/3; - backend_get_closest_colour(&col); - xvpic_pal[n]=col.pixel; - } + int r,g,b; + int n; + + for(n=0,r=0;r<8;r++) { + for(g=0;g<8;g++) {/* colours are 3:3:2 */ + for(b=0;b<4;b++,n++) { + xvpic_pal[n][0]=r*0xff/7; + xvpic_pal[n][1]=g*0xff/7; + xvpic_pal[n][2]=b*0xff/3; + } + } + } } GdkPixmap *xvpic2pixmap(unsigned char *xvpic,int w,int h,GdkPixmap **smallp) { GdkPixmap *pixmap,*small_pixmap; -GdkImage *image; +guint8 *buffer; unsigned char *ptr=xvpic; int x,y; int small_w,small_h; if(w==0 || h==0) return(NULL); -/* we allocate pixmap and image, draw into image, copy to pixmap, - * and ditch the image. - */ - -if((image=gdk_image_new(GDK_IMAGE_FASTEST,backend_get_visual(),w,h))==NULL) - return(NULL); - -if((pixmap=gdk_pixmap_new(mainwin->window,w,h, - gdk_visual_get_best_depth()))==NULL) - { - gdk_image_destroy(image); - return(NULL); - } -for(y=0;ystyle->white_gc,image,0,0,0,0,w,h); -gdk_flush(); +if (NULL == (pixmap=gdk_pixmap_new(mainwin->window,w,h, -1))) { + return(NULL); +} -/* reuse image to draw scaled-down version for thin rows */ small_w=w/ROW_HEIGHT_DIV; small_h=h/ROW_HEIGHT_DIV; if(small_w==0) small_w=1; if(small_h==0) small_h=1; -if((small_pixmap=gdk_pixmap_new(mainwin->window,small_w,small_h, - gdk_visual_get_best_depth()))==NULL) - { - gdk_pixmap_unref(pixmap); - gdk_image_destroy(image); - return(NULL); +if((small_pixmap=gdk_pixmap_new(mainwin->window,small_w,small_h,-1))==NULL) +{ + gdk_pixmap_unref(pixmap); + return(NULL); +} + +buffer = malloc (w * h * sizeof (guint8) * 3); + +if (NULL == buffer) { + /* malloc failed */ + gdk_pixmap_unref(pixmap); + gdk_pixmap_unref(small_pixmap); + return NULL; +} + + +for(y=0;ystyle->white_gc,0,0,w,h, + GDK_RGB_DITHER_NORMAL, + (guchar*)buffer, w * 3); +gdk_flush(); + +/* reuse image to draw scaled-down version for thin rows */ -for(y=0;ystyle->white_gc,image, - 0,0,0,0,small_w,small_h); +for(y=0;ystyle->white_gc,0,0,small_w, small_h, + GDK_RGB_DITHER_NORMAL, + (guchar*)buffer, small_w * 3); *smallp=small_pixmap; + +if (NULL != buffer) { + free (buffer); +} + return(pixmap); } @@ -3649,7 +3665,11 @@ }; +gtk_widget_push_visual(gdk_rgb_get_visual()); +gtk_widget_push_colormap(gdk_rgb_get_cmap()); mainwin=gtk_window_new(GTK_WINDOW_TOPLEVEL); +gtk_widget_pop_visual(); +gtk_widget_pop_colormap(); GTK_WIDGET_UNSET_FLAGS(mainwin,GTK_CAN_FOCUS); gtk_signal_connect(GTK_OBJECT(mainwin),"destroy", GTK_SIGNAL_FUNC(cb_quit),NULL);