[cairo] Pixel RGB Values...

Steril 707 steril707 at hotmail.com
Fri Jul 10 05:10:02 PDT 2009


Hmm, i wanna build a pipette tool, for getting the colorvalue at a certain pixel on my cairo_surface_t.

here is some code which I found on this list, which doesn't seem to work in my case...



void pipette (int x, int y) //arguments are coordinates the mouse
{
cairo_surface_t* imageSurface;

imageSurface=layers[model->getCurrentLayer]->getSurface() ;  //gets one of my apps layers surface

unsigned* char data = cairo_image_surface_get_data(imageSurface);

int stride=  cairo_image_surface_get_stride(imageSurface);

unsigned char* pixelRGB = data+(y*stride) + (x*CAIRO_FORMAT_ARGB32);

printf ("pixel rgb: %i \n", (int) pixelRGB);

}


This seems to only return me the adress of that pixel in int. Well, that's my guess, since the number gets higher and higher if i move the mousepointer to the bottom right corner of the window, and lower in the other direction.

Any idea for me?


Thanks,
Mike



> Date: Thu, 9 Jul 2009 11:48:47 +0200
> From: david at bjorkevik.se
> To: steril707 at hotmail.com
> CC: cairo at cairographics.org
> Subject: Re: [cairo] Pixel RGB Values...
> 
> Steril 707 wrote:
> > I am working on a little image processing app, and would need to be
> > able to get the RGB values of certain pixels on a surface. Is there
> > any way to do that already with cairo at the moment? I cannot find
> > anything in the API reference on that, so I thought I should ask you
> > people here... And, if that's not possible, are there any plans for
> > this to get implemented?
> 
> In your question you are making an assumption: that surfaces are made
> out of pixels. This is certainly not always the case, for instance with
> Postscript or PDF surfaces.
> 
> Perhaps you can give us some more info on what you want to achieve in
> your application?
> 
> Regards,
> David

_________________________________________________________________
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20090710/5721efa8/attachment.htm 


More information about the cairo mailing list