After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 83244 - GdkRgbCmap not wrapped
GdkRgbCmap not wrapped
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.0
Other All
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2002-05-28 12:51 UTC by Olivier Samyn
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Olivier Samyn 2002-05-28 12:51:08 UTC
There's no wrapper for the GdkRgbCmap gdk object.

This object is used in the draw_indexed_image method from Gdk::Drawable.
Comment 1 Murray Cumming 2002-06-15 18:34:57 UTC
Could you show us an example of how it would be used in C?
Comment 2 Daniel Elstner 2002-06-15 18:59:12 UTC
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
Comment 3 Murray Cumming 2002-06-16 14:53:44 UTC
Yes, maybe, but I'd still like to see how it's used. It's just a
little struct and 2 associated functions.
Comment 4 Olivier Samyn 2002-06-17 08:41:34 UTC
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.
Comment 5 Murray Cumming 2002-06-18 19:25:34 UTC
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.
Comment 6 Olivier Samyn 2002-06-19 08:23:39 UTC
I juste added a new bug (#85911) to continue discussions about
Gdk::Drawable draw_..._image functions.
Comment 7 Murray Cumming 2002-06-19 12:07:23 UTC
How do we know how big the rgb_buf array should be?
Comment 8 Murray Cumming 2002-06-19 12:28:52 UTC
Sorry, last comment added to wrong bug.
Comment 9 Murray Cumming 2002-06-22 12:32:41 UTC
Gdk::RgbCmap added, and used in draw_indexed_image(). Thanks.