Re: Problems with fillpatterns and Gtk for Windows



Guenther Sohler writes:
On Linux and Unix my testcase works fine.

On what kind of visuals, what kind of machines? It doesn't work for me
on Linux on a x86, on a 24-bit default TrueColor visual. I get a
uniform (random?) colour in the window, like on Windows.

What is wrong ?

        GdkColor red;
        GdkColor green;
        GdkPixmap *fillpat;

        char pattern[8]={0xff,0x81,0xbe,0xa5,0xa5,0xbe,0x81,0xff};
        green.red=0x0000; green.green=0xffff; green.blue=0x0000;
        red.red=0xffff; red.green=0x0000; red.blue=0x0000;

        gdk_color_alloc(gdk_colormap_get_system(),&green);
        gdk_color_alloc(gdk_colormap_get_system(),&red);

        fillpat=gdk_pixmap_create_from_data(NULL,pattern,8,8,1, &green,&red);

I certainly don't understand these things fully and by heart, and
might be confused here, but isn't it a bit odd to create a depth=1
pixmap, and then pass truecolor pixel values as foreground and
background? Shouldn't you pass GdkColors with the pixel field set to
either zero or one?

When I changed the above snippet like this:

--- sohler-1.c  Fri Aug  4 12:55:28 2006
+++ sohler-2.c  Fri Aug  4 14:00:32 2006
@@ -8,4 +8,5 @@
         printf("realize\n");
 
+        GdkColor zero, one;
         GdkColor red;
         GdkColor green;
@@ -19,5 +20,8 @@
         gdk_color_alloc(gdk_colormap_get_system(),&red);
 
-        fillpat=gdk_pixmap_create_from_data(NULL,pattern,8,8,1, &green,&red);
+        zero.pixel = 0;
+        one.pixel = 1;
+
+        fillpat=gdk_pixmap_create_from_data(NULL,pattern,8,8,1, &zero,&one);
 
         gc=gdk_gc_new(widget->window);

it works fine both on Linux and Windows for me.

--tml




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]