Daniel Elstner schrieb: > Most likely because the Gtk::Image widget isn't realized yet at this > point, which means its Gdk::Window doesn't exist yet.
Ok, that sounds pretty reasonable. >> I >> know, that this is a very bad solution, because I use the complete >> (derived) Gtk:Image as Drawable, > > I don't see where you do that. It wouldn't work anyway. (Gtk::Image is > *not* a Gdk::Drawable). Ok, my description was at that point of writing very bad. If it was that easy, I surely didn’t want to convert the Pixbuf into a Drawable before… What I meant, but unfortunately didn’t say: I just want to manipulate the loaded image, not the stuff around. But that’s not really relevant at this point. >> although I only want to modify its >> Pixbuf, but that was just a try whether it works or not. > > Gtk::Image is a widget that can display some image. It does not by > itself maintain the image data. Modifying its Gdk::Pixbuf means just > assigning a new one. Understood. > Well, I had a look and it's indeed there. There cannot possibly be any > documentation because it is useless and doesn't work. It seems to have > been added by accident. Congratulations, you are the first person to > notice this, even though it must have been around for about a > decade. :-) Oh, what honour. :) > You've got it completely the wrong way around. Cairo does simple > client-side drawing. Using Gdk::Drawable means you are communicating > with the X server. Gdk::Image is client-side, but still comes with all > the Xlib complexity like visuals and color maps and what not. > > If you really only want to work with pixels, you can just access > Gdk::Pixbuf directly. From the top of my head: > > // Assume we have an RGB pixbuf with 8 bits per component > g_assert(pixbuf->get_colorspace() == Gdk::COLORSPACE_RGB); > g_assert(pixbuf->get_bits_per_sample() == 8); > > guint8 *const pixel = pixbuf->get_pixels() > + row * pixbuf->get_rowstride() > + col * pixbuf->get_n_channels(); > pixel[0] = red; > pixel[1] = green; > pixel[2] = blue; > > I think there was a libart or something to encapsulate this, but it's > rarely used these days. From my point of view, either you are drawing > at a high level and use Cairo, or you want to deal with raw pixel data > in which case setting single pixels in isolation would be unacceptably > slow, so you would work on the buffer as a whole. Thank you for this clarification. My whole experience with GTKMM/GTK+ relates to only a few weeks, so I am far away from understandig the whole complexity of all part libraries. >>> Ok, you suggest to take Gdk::Pixmap for this stuff. Well, how do I >>> convert the Gdk::Pixbuf into a Gdk::Pixmap? > > No, I didn't suggest to use Gdk::Pixmap. Well, maybe I suggested it, > but I certainly don't recommend it. :-) What I meant was that > Gdk::Pixmap would be a Gdk::Drawable which you can instantiate. In > other words, it would work, but still be a bad idea for what you are > doing. > > Generally, I think you need to step back for a moment and think things > over. Your current attempt makes it look way more complicated than it > actually is. Well, you offered me some new ideas that I will have to think about. With the present approach I won’t get much success, so a restructuration is probably a nice idea. Thank you very much for your help! Greetings, Falk _______________________________________________ gtkmm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkmm-list
