[cairo] Transparency troubles with PNGs on Windows
Brad Elliott
brad_e at hotmail.com
Sun Mar 11 18:42:22 PDT 2007
Hello,I'm trying to create transparent PNGs and I'm running into a problem where the surface doesn't get cleared when I destroy a cairo+surface pair under Windows. Then when I create a second object there is data left around (a red rectangle) from the original cairo object which corrupts the second image. I suspect that I'm tearing down something incorrectly and the reference counts don't drop to zero (cairo_surface_get_reference_count() doesn't seem to be available on the Windows build on Tor Lillquist's page). Has anyone encountered this before?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
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/cairo/attachments/20070312/226c2e27/attachment.html
More information about the cairo
mailing list