Re: Pixel color



On 5/28/07, Francis BACQUE <fbacque free fr> wrote:
how can I retrieve the color of a pixel at x,y coordinates of a
Gdk::Pixbuf?

I have a set of helpers here:

 http://people.iola.dk/olau/misc/pixbuf-drawing.hpp

You instantiate a PixelPosition with get_position(pixbuf, x, y). The
pixel position can be moved around efficiently, and you can get to the
pixel underneath with PixelPosition::pixel(), e.g.

 Pixel p = get_position(pixbuf, x, y).pixel();
 p.red() = 0xFF;
 p.green() = 0xAF;
 p.blue() = 0xAF;
 p.alpha() = 0x50;

There's also PixelIterator for iterating through all pixels of a pixbuf.

--
Ole Laursen
http://www.iola.dk/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]