Re: problem with drawing 32bit image to 16bit screen (works with 32/24 bit screen)



Havoc Pennington wrote:

Patrick Sung <phsung ualberta ca> writes:

I was trying to draw a 32bit color image to both a 24bit system and
16 bit systems.  I got the 24bit system works but not the 16 bit
systems. It seems that gdk isn't reading my 32bit color image
properly because I got an image displayed twice adjacent to each
other (on the 16bit system).


Can you send us a small test case? This should certainly work.


I can do it, but for now I can give you more information.

The data comes from an XImage object (which some library is providing). I read off the XImage.data to get to the real data. I also read the other fields in the XImage struct. The following is the printf of those fields:

width:[640] height:[482]
depth:[24] bytes per line:[2560], bits_per_pixel:[32]
image format:[2] (That's XYPixmap, but I don't think it makes any difference, unless it say it is a bitmap)
bitmap_unit:[32]
bitmap_pad:[32]

Both the system give me the same XImage data.

btw, the screen output of the 16bit system has different color (they are not entirely black and white (yes, I am taking b/w image using 32bit of color ;) )

The call I used to draw the RGB image is:

     gdk_draw_rgb_32_image (draw_area->window,
                draw_area->style->bg_gc[GTK_STATE_NORMAL],
                0,0,640,482,
                GDK_RGB_DITHER_NONE,
                buffer,
                640*4);

draw_area is the gtk_drawing_area.

Is that the *right way* to provide the GDKDrawable and GC to the function?


Initialization is like this:

 gtk_init (&argc, &argv);
 gdk_rgb_init ();


The main window and d_area is drawn like this:

 gtk_widget_push_visual (gdk_rgb_get_visual ());
 gtk_widget_push_colormap (gdk_rgb_get_cmap ());

 main_win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 accel_group = gtk_accel_group_new ();

 gtk_container_set_border_width (GTK_CONTAINER (main_win), 2);
 gtk_window_set_title (GTK_WINDOW (main_win), "Image Capture");
 gtk_window_add_accel_group (GTK_WINDOW (main_win), accel_group);

 vbox = gtk_vbox_new (FALSE, 2);
 gtk_container_add (GTK_CONTAINER (main_win), vbox);

 /* drawing area */
 draw_area = gtk_drawing_area_new ();
 gtk_drawing_area_size (GTK_DRAWING_AREA (draw_area), 640, 482);
 gtk_box_pack_start (GTK_BOX (vbox), draw_area, FALSE, FALSE, 0);

 statusbar = gtk_statusbar_new ();
 gtk_box_pack_end (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0);

 gtk_widget_pop_visual ();
 gtk_widget_pop_colormap ();


By the way, is gdk_draw_gray_image() use data in packed 8-bit
instead of using data with each 32bit word as one pixel which
contains only 8-bit of useful data?


I believe it's 8-bit packed data.



Thanks,
Patrick





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