[cairo] Problem with PNG file and CAIRO_SCALE

Steve Harrington steven.harrington at comcast.net
Thu Nov 25 09:25:43 PST 2010


On 11/25/2010 07:09 AM, Dov Grobgeld wrote:
> My guess is that the source of the problem is explained in the 
> following quote from the cairo-xlib-surface documentation:
>
> Currently, only TrueColor visuals are fully supported.
>
> which means that you don't have alpha support when drawing. One way of 
> solving this is to create a second image surface on which you do your 
> drawing that you then draw to the xlib-surface without any scaling. 
> This basically means keeping an entire copy of the window as a 
> backstore image that you then copy to the xlib-surface when needed.
>
> Perhaps someone else can give a better solution.
>
> Regards,
> Dov
I don't know about a better solution but one that works for me is to use 
gd (gd-2.0.36 is available under Ubuntu) to load and scale the image.  I 
have attached an example program  that displays a very large jpeg image 
(21600X10200 pixels, yes really 200M+ pixels) from the NASA Big Blue 
Earth collection (i.e. 
http://visibleearth.nasa.gov/view_rec.php?id=7106).  Loading the 
original image takes a few seconds but then scaling / translating is 
faster than you can see.

Some notes:

     As noted above you need true four channel images so the expose 
handler must add an alpha channel.

     This example uses jpeg support but gd also has png support

     This example program is just the init and expose handler.  If 
anyone is interested I can post the driver as well.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20101125/ef2c6141/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DrawWorld.c
Type: text/x-csrc
Size: 5643 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20101125/ef2c6141/attachment-0001.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DrawWorld.h
Type: text/x-chdr
Size: 156 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20101125/ef2c6141/attachment-0001.h>


More information about the cairo mailing list