Re: [gtk-list] Displaying image using Gdk/Gtk




> I'm currently trying to write a program to display bitmap file using
> gdk/gtk. 

Imlib http://www.labs.redhat.com/imlib/ or gdk_image_new_bitmap() may be
the easiest way to do this.

> What I have tried so far is: after extracting the bitmap info header
> and the pixel streams, I create a new GdkImage using 'gdk_image_new'
> (the 'Visual' parameter required by 'gdk_image_new' was determined by
> using 'gdk_visual_get_system'). Then I set the other attributes
> (GdkImage.bpp, GdkImage.bpl and GdkImage.mem) manually as they r not
> pass as parameters when creating the GdkImage. With that, I proceed to
> create a GtkWidget with 'gtk_image_new' (passing the GdkImage as
> parameter) and add it to a container for display. The result is a
> window with the image size but without the image.

If you are determined to do it yourself, I may be incorrect, but I don't
think you want to manually manipulate the bpp or bpl fields.  Those I
believe are determined by your visual and you are required to conform to
them.  If you want to convert bits to pixels manually you should access
the underlying ximage using the GDK_IMAGE_XIMAGE macro.

--josh

----------------------------------------------------------------
                       Joshua Richardson
Dept. Cognitive and Neural Systems / Center for Adaptive Systems
                       Boston University
----------------------------------------------------------------



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