[cairo] render in grayscale

Behdad Esfahbod behdad at behdad.org
Tue Sep 22 10:08:06 PDT 2009


On 09/22/2009 01:00 PM, Bill Spitzak wrote:
> I think the original poster wants to render not the alpha, but something
> like (r+g+b)/3 of the image as grayscale.

That's exactly what the solution Kalle and I proposed does.  Though, one 
typically wants a non-uniform combination of rgb for grayscale, with green 
getting a larger multiplier.

behdad

> This is probably not possible, except by getting the image data and
> applying the math as you copy each pixel to a new image.
>
> If Cairo was to directly support this perhaps it would be an image
> processing operation like blurring and so on, that might be applied to a
> source image as part of some future filtering stack api.
>
> Kalle Vahlman wrote:
>> 2009/9/22 Per Hermansson <hermansson.per at bredband.net>:
>>> Thanks for the help and quick reply, I only get a black area when I try
>>> the code below:
>


More information about the cairo mailing list