<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body><div style="text-align: left;">Hello,<br><br>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?<br><br>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.<br><br>Incorrect output on Windows:<br> http://bradford.elliott.googlepages.com/one_windows.png<br> http://bradford.elliott.googlepages.com/two_windows.png (red rectangle is left around from one_windows.png)<br>
<br>Correct output on Linux:<br> http://bradford.elliott.googlepages.com/one_linux.png<br> http://bradford.elliott.googlepages.com/two_linux.png (no red rectangle which is what I expect)<br><br>Can anyone tell me what I'm doing wrong? Any help would be appreciated.<br><br>Thanks,<br><br>Here is a short snippet demonstrating the problem:<br><br> #include <cairo.h><br> <br> void draw(const char* output_file, int x, int y)<br> {<br> cairo_t* image;<br> cairo_surface_t* surface;<br> int width = 126;
<br> int height = 24;<br> <br> surface = cairo_image_surface_create<wbr>(CAIRO_FORMAT_ARGB32, width, height);<br> image = cairo_create(surface);<br> <br> cairo_rectangle(image, x, y, 20, 20);<br>
cairo_set_source_rgba(image, 0,0,0,1);<br> cairo_fill(image);<br> <br> cairo_surface_write_to_png<wbr>(surface, output_file);<br> cairo_surface_destroy(surface);<br> cairo_destroy(image);<br> }<br><br> int main(void)
<br> {<br> draw("one.png", 0, 0);<br> draw("two.png", 10, 10);<br> }<br>
<br></div><br /><hr />Explore the seven wonders of the world <a href='http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE' target='_new'>Learn more!</a></body>
</html>