GNOME Bugzilla – Bug 83244
GdkRgbCmap not wrapped
Last modified: 2004-12-22 21:47:04 UTC
There's no wrapper for the GdkRgbCmap gdk object. This object is used in the draw_indexed_image method from Gdk::Drawable.
Could you show us an example of how it would be used in C?
Ahh, I found it in the docs. This doesn't seem to be deprecated, so I think we should add it to our TODO list. A patch would be nice, though. --Daniel
Yes, maybe, but I'd still like to see how it's used. It's just a little struct and 2 associated functions.
Here's a part of a more complex code using the GdkRgbCmap. void TestModule::render( Glib::RefPtr<Gdk::Drawable> drawZone, Glib::RefPtr<Gdk::GC> gc) { if(!readyToDisplay) return; GdkRgbCmap * rgbmap; guint32 *colors; colors = new guint32[256]; guint32 val; for(int i=0;i<256;i++) { val = i; colors[i] = createRGBColor(64, 64, val); } colors[0] = createRGBColor(255, 255, 255); rgbmap = gdk_rgb_cmap_new(colors, 256); drawZone->draw_indexed_image( gc, 0, 0, width, height, Gdk::RGB_DITHER_NONE, table, width, *rgbmap); gdk_rgb_cmap_free(rgbmap); delete []colors; } Some comments: - the goal of this function is to display an indexed image contained in table (this image is a computed image... like a fractal). Table is a of type gchar*... - createRGBColor is a simple Macro. As you can see, GdkRgbCmap is just a vector of guint32 containing a color map. A C++ version of GdkRgbCmap can be created to handle this structure. Also, I think there is a problem with draw_indexed_image that only use C types and structures. Maybe adding the same function with following prototype will be usefull: draw_indexed_image( const Glib::RefPtr<const GC>& gc, int x, int y, int width, int height, RgbDither dith, std::vector &rgb_buf, GdkRgbCmap& cmap) The same changes can maybe applied to other functions like draw_rgb_image draw_rgb32_image ... For my part I'm currently working on another project I want to launch... so I don't have many time to create a patch now (also I'm not already familiar with the internal gtkmm code)... maybe in a couple of weeks... Also this function isn't really usefull for my project... I just posted this because I think if gtkmm wants to become a full C++ wrapper for gtk, it have to wrap all existing classes.
Regarding the methods, here is the existing signature: _WRAP_METHOD(void draw_indexed_image( const Glib::RefPtr<const GC>& gc, int x, int y, int width, int height, RgbDither dith, const guchar* rgb_buf, int rowstride, GdkRgbCmap& cmap), gdk_draw_indexed_image) and here is a URL for the C function's documentation: http://developer.gnome.org/doc/API/2.0/gdk/gdk-gdkrgb.html#gdk-draw-indexed-image I think it is just a const guchar* parameter that he is complaining about. I guess that it would contain lots of data so it might not be worth putting it into and out of a vector. Also, I don't know how much data should be there. It seems to be ? rows of data, of size rowstride. Do we need to use the width and height to calculate the size of the data? This really should be a separate bug.
I juste added a new bug (#85911) to continue discussions about Gdk::Drawable draw_..._image functions.
How do we know how big the rgb_buf array should be?
Sorry, last comment added to wrong bug.
Gdk::RgbCmap added, and used in draw_indexed_image(). Thanks.