Re: [gtkmm] pixmap to pixbuf conversion
- From: Ole Laursen <olau hardworking dk>
- To: gtkmm-list gnome org
- Subject: Re: [gtkmm] pixmap to pixbuf conversion
- Date: 18 Jan 2003 18:32:37 +0100
Tobias Roth <roth iam unibe ch> writes:
[...]
> Now, if I want to edit the buffer, e.g. apply some filters, I read
> the buffer in an array using
>
> guint8* get_pixels () const
>
> to get a pointer to the actual pixel data. This data is in the
> format 'first pixel r value, first pixel g value, first pixel
> b value, second pixel r value, second pixel g value and so on'.
> So you need an array width*height*3 to hold all the rgb values
> or three width*height arrays to hold the three color 'planes'.
> If you have an alpha channel, the format is rgbargba and the
> array size is width*height*4.
>
> Then fiddle with the array, and finally write it back to the buffer
> with Gdk::Pixbuf::create_from_data(...).
Maybe I've misunderstood you, but I think this is wrong. The pointer
you get from get_pixels is a pointer into the pixbuf datastructure. So
you don't have to write anything back, you're changing the actual data.
The interface isn't very nice, though. I have a _much_ better one
which uses iterators and can be used to access pixels directly - if
you are interested, you can have a look here:
http://www.cs.auc.dk/~olau/misc/pixbuf-drawing.hpp
There is test example here:
http://www.cs.auc.dk/~olau/misc/test.cpp
I want to do some timings with GCC 3.2 before I write documentation
and announce it. If you have GCC 3.2, I would be very grateful if you
would run
time ./test 1
time ./test 2
time ./test 3
time ./test 4
time ./test 5
time ./test 6
and send the results. A compilation command is at the top of the
test.cpp file.
--
Ole Laursen
http://www.cs.auc.dk/~olau/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]