What is the difference between GtkImage, GdkImage, GdkPixmap and GdkBitmap?

2008-01-25 Thread LIU Chun Hung
Hi all,

I don't know the difference between these types(GtkImage, GdkImage,
GdkPixmap and GdkBitmap) although I have read the GTK and GDK API
Reference Manual.

Suppose I want to create a new RGB bitmap with 3 x 3 in size and I want to
set all pixel values to be 0. After clicking a button, all pixel values
will change to 255. Which one of the above types should I use? Should
GdkImage be used as I can see there are functions to change the pixel
values (gdk_image_put_pixel) in this type, but not in other types.

But when I use this type to create a bitmap, this function (gdk_image_new)
is used. There is a parameter with the type (GdkVisual*) which I don't
know how to set/initialize. When I use gdk_visual_get_system  
(void) to initialize the type of GdkVisual*, I can compile it. But when I
run it, there are some errors as below and the bitmap cannot be generated.

example_font_selector[8794]: GLIB CRITICAL ** GLib-GObject - gtype.c:2217:
initialization assertion failed, use IA__g_type_init() prior to this
function
example_font_selector[8794]: GLIB CRITICAL ** Gdk -
gdk_screen_get_system_visual: assertion `GDK_IS_SCREEN (screen)' failed
example_font_selector[8794]: GLIB CRITICAL ** GLib-GObject - gtype.c:2217:
initialization assertion failed, use IA__g_type_init() prior to this
function
example_font_selector[8794]: GLIB CRITICAL ** Gdk - gdk_visual_get_screen:
assertion `GDK_IS_VISUAL (visual)' failed
example_font_selector[8794]: GLIB CRITICAL ** Gdk -
_gdk_image_new_for_depth: assertion `visual || depth != -1' failed

Thank you for your kind attention.

Regards,
Hung


___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: What is the difference between GtkImage, GdkImage, GdkPixmap and GdkBitmap?

2008-01-25 Thread Kaj-Michael Lang
On Fri, 25 Jan 2008, LIU Chun Hung wrote:

 example_font_selector[8794]: GLIB CRITICAL ** GLib-GObject - gtype.c:2217:
 initialization assertion failed, use IA__g_type_init() prior to this
 function

You need to initialize the glib type system before using the gtk/glib 
functions. Put g_type_init(); somewhere in your code before using any 
other functions.

-- 
Kaj-Michael Lang
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: What is the difference between GtkImage, GdkImage, GdkPixmap and GdkBitmap?

2008-01-25 Thread LIU Chun Hung
 Suppose I want to create a new RGB bitmap with 3 x 3 in size and I want
 to
 set all pixel values to be 0. After clicking a button, all pixel values
 will change to 255. Which one of the above types should I use? Should
 GdkImage be used as I can see there are functions to change the pixel
 values (gdk_image_put_pixel) in this type, but not in other types.

 You would use a GdkImage to manipulate the pixels, and a GtkImage to
 display it.

Yes, it is exactly what I want to do, but I don't know how to do it. Can
anyone guide me to do it?

The first thing to do is to create a new GdkImage. I use this function,
gdk_image_new(GdkImageType type, GdkVisual *visual, gint width, gint
height) to create.

type = GDK_IMAGE_SHARED;
width = 3;
height = 3;
visual = ?

For the GdkVisual*, I don't know how to initialize it.
I have tried with different methods as below, but errors will occur when I
run the program.

visual = gdk_visual_get_system();
example_font_selector[11303]: GLIB CRITICAL ** Gdk -
gdk_screen_get_system_visual: assertion `GDK_IS_SCREEN (screen)' failed

visual = gdk_visual_get_best();
qemu: uncaught target signal 11 (Segmentation fault) - exiting

visual = gdk_visual_get_best_with_depth(8);
qemu: uncaught target signal 11 (Segmentation fault) - exiting

visual = gdk_visual_get_best_with_type(GDK_VISUAL_TRUE_COLOR);
qemu: uncaught target signal 11 (Segmentation fault) - exiting

visual = gdk_visual_get_best_with_both(8, GDK_VISUAL_TRUE_COLOR);
qemu: uncaught target signal 11 (Segmentation fault) - exiting

In fact, which one should I use?

___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: What is the difference between GtkImage, GdkImage, GdkPixmap and GdkBitmap?

2008-01-25 Thread Marius Gedminas
On Fri, Jan 25, 2008 at 05:36:43PM +0800, LIU Chun Hung wrote:
 I don't know the difference between these types(GtkImage, GdkImage,
 GdkPixmap and GdkBitmap) although I have read the GTK and GDK API
 Reference Manual.

Disclaimer: IANAEGD (I Am Not An Experienced Gtk+ Developer).

GtkImage is a widget that you can stick into a window to display image
data (stored in a GdkImage).

GtkPixmap is a widget that you can stick into a window to display image
data (stored in a GdkPixmap).

The difference between an image and a pixmap is that the image is stored
on the client and transfers pixel data to the X server on every redraw
request, while a pixmap is stored on the X server.  Usually this is more
efficient, but if you plan to modify the image, you cannot use pixmaps.

A GdkBitmap is a *bit* map: it's a 1-bit per pixel image, usually used
for things like transparency maps.

 Suppose I want to create a new RGB bitmap with 3 x 3 in size and I want to
 set all pixel values to be 0. After clicking a button, all pixel values
 will change to 255. Which one of the above types should I use? Should
 GdkImage be used as I can see there are functions to change the pixel
 values (gdk_image_put_pixel) in this type, but not in other types.

You would use a GdkImage to manipulate the pixels, and a GtkImage to
display it.

Marius Gedminas
-- 
All programs evolve until they can send email.
-- Richard Letts
Except Microsoft Exchange.
-- Art
(found on the Snort web site)


signature.asc
Description: Digital signature
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers