[cairo] Transparency troubles with PNGs on Windows

Owen Taylor otaylor at redhat.com
Mon Mar 12 05:59:50 PDT 2007


It's really very simple here ... an image surface isn't cleared
or initialized in any way 


> 
> The following is an example demonstrating this problem on Cairo 1.4.0.
> When I make the second call to draw() the contents of the original
> surface are left around in the second image (red rectangle).  Am I
> doing something wrong in tearing down the surface/cairo object? It
> works fine under Linux but not under Win32 (Visual Studio .Net 2003
> under XP) using the library provided by Tor.
> 
> Incorrect output on Windows:
>     http://bradford.elliott.googlepages.com/one_windows.png
>     http://bradford.elliott.googlepages.com/two_windows.png (red
> rectangle is left around from one_windows.png)
> 
> Correct output on Linux:
>     http://bradford.elliott.googlepages.com/one_linux.png
>     http://bradford.elliott.googlepages.com/two_linux.png (no red
> rectangle which is what I expect)
> 
> Can anyone tell me what I'm doing wrong? Any help would be
> appreciated.
> 
> Thanks,
> 
> Here is a short snippet demonstrating the problem:
> 
>    #include <cairo.h>
>    
>    void draw(const char* output_file, int x, int y)
>    {
>       cairo_t*         image;
>       cairo_surface_t* surface;
>       int              width  = 126; 
>       int              height = 24;
>     
>       surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width,
> height);
>       image = cairo_create(surface);
>     
>       cairo_rectangle(image, x, y, 20, 20);
>       cairo_set_source_rgba(image, 0,0,0,1);
>       cairo_fill(image);
>     
>       cairo_surface_write_to_png(surface, output_file);
>       cairo_surface_destroy(surface);
>       cairo_destroy(image);
>    }
> 
>    int main(void) 
>    {
>       draw("one.png", 0, 0);
>       draw("two.png", 10, 10);
>    }
> 
> 
> 
> 
> ______________________________________________________________________
> Explore the seven wonders of the world Learn more!
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo



More information about the cairo mailing list