[cairo] Pixels data mismatch while loading image with OpenCv and CairoGraphics

Maarten Bosmans mkbosmans at gmail.com
Thu Sep 15 00:16:32 PDT 2011


2011/9/15 Deepak Kumar JAIN <deepak19dec at gmail.com>:
> Thanks Maarten for the advice. OpenCV loads the image in RGB format but
> Cairo Loads in PRGB(Pre multiplied with Alpha channele). hence while loading
> the image, I convert the 3 channel image to 4 channel in OpenCV and then
> pass the resulting image to Cairo and then I get the perfect result.
>
> Thanks all for the advice. But still I can't find how can I check for the
> format of the image as I create the surface from data and its need to have
> format as parameter.

I'm not sure what you want to accomplish.
For loading a bunch of bytes that you get from opencv into cairo, you
should use cairo_image_surface_create_for_data(), where you can
specify image format, stride, etc.

http://cairographics.org/manual/cairo-Image-Surfaces.html#cairo-image-surface-create-for-data

Maarten

> Thanks for the advices.
>
> Deepak
>
> On Wed, Sep 14, 2011 at 6:18 PM, Maarten Bosmans <mkbosmans at gmail.com>
> wrote:
>>
>> 2011/9/14 Deepak Kumar JAIN <deepak19dec at gmail.com>:
>> > Hello All,
>> >
>> > When I load the same png image in OpenCV and cairoGraphics, I see that
>> > the
>> > data of the image is not same.
>> >
>> >
>> > http://postimage.org/image/vlpntz38/
>> >
>> > Image can be seen here. I see that every 4th data entry in after I get
>> > data
>> > from surface has value of 255. I dont know why.
>> >
>> > Can anyone give the explanation of this?
>>
>> OpenCV is probably expecting RGB, while cairo is providing ARGB data.
>>
>> Try constructing a 24bpp ImageSurface.
>>
>> Maarten
>>
>> > Thanks,
>> > Deepak
>> >
>> >
>> >
>> > --
>> >
>> > Thanks & Regards,
>> > Deepak Kumar JAIN
>> > Internship student,
>> > Orange Labs,France Telecom,
>> > Rennes, France
>> > Contact: +33(0)6 31 15 44 66
>> > www.deepakkumarjain.co.cc
>> >
>> > "I err therefore I am "- Saint Augustine
>> >
>> >
>> > --
>> > cairo mailing list
>> > cairo at cairographics.org
>> > http://lists.cairographics.org/mailman/listinfo/cairo
>> >
>
>
>
> --
>
> Thanks & Regards,
> Deepak Kumar JAIN
> Internship student,
> Orange Labs,France Telecom,
> Rennes, France
> Contact: +33(0)6 31 15 44 66
> www.deepakkumarjain.co.cc
>
> "I err therefore I am "- Saint Augustine
>
>


More information about the cairo mailing list