[cairo] CAIRO_FORMAT_A1 image source color

sthustfo sthustfo at gmail.com
Tue Apr 1 10:32:38 PDT 2014


Looking through the cairo source for cairo_surface_write_to_png(), I see
that the surface data is coerced to CAIRO_FORMAT_A8 (using pixmap routine).
But still unable to identify where in png routines, the data is converted
to monochrome? The data returned by cairo_image_surface_get_data() is all
0xff's. Any pointers would be appreciated.

Is there any other way to accomplish this?

Thanks.



On Mon, Mar 31, 2014 at 5:36 PM, sthustfo <sthustfo at gmail.com> wrote:

> Thanks, the example works perfectly.
>
> However, I have a further query. You mentioned earlier that
>
> >Please note that CAIRO_FORMAT_A1 and CAIRO_FORMAT_A8 are *not* monochrome
> >images. They describe images without any colors at all which only contain
> an
> >alpha channel. Only when generating a PNG are these images interpreted as
> >monochrome.
>
> Now suppose I want to get access to the raw A1 (monochrome) data using
> cairo_image_surface_get_data(), then this is not possible because as you
> mentioned it contains only alpha channel. The interpretation happens during
> PNG writing. Is there any way around this? One option I can think of is to
> take a look at how cairo_surface_write_to_png() operates on the data (alpha
> channel), and similarly implement the same to get access to raw data.
>
> Thanks.
>
>
>
> On Sun, Mar 30, 2014 at 5:01 PM, Uli Schlachter <psychon at znc.in> wrote:
>
>> On 29.03.2014 19:48, Uli Schlachter wrote:
>> [...]
>> > Anyway, attached is a quick example for this.
>> [...]
>>
>> I hate it when this happens. Now with attachment and, just because I can,
>> the
>> resulting PNG!
>>
>> Uli
>> --
>> A learning experience is one of those things that say,
>> 'You know that thing you just did? Don't do that.'
>>                      -- Douglas Adams
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20140401/e91edf1b/attachment.html>


More information about the cairo mailing list