<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).&nbsp; 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>&nbsp;&nbsp;&nbsp; http://bradford.elliott.googlepages.com/one_windows.png<br>&nbsp;&nbsp;&nbsp; http://bradford.elliott.googlepages.com/two_windows.png (red rectangle is left around from one_windows.png)<br>
<br>Correct output on Linux:<br>&nbsp;&nbsp;&nbsp; http://bradford.elliott.googlepages.com/one_linux.png<br>&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp; #include &lt;cairo.h&gt;<br>&nbsp;&nbsp; <br>&nbsp;&nbsp; void draw(const char* output_file, int x, int y)<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_t*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; image;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_surface_t* surface;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width&nbsp; = 126;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height = 24;<br>&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; surface = cairo_image_surface_create<wbr>(CAIRO_FORMAT_ARGB32, width, height);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; image = cairo_create(surface);<br>&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_rectangle(image, x, y, 20, 20);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_set_source_rgba(image, 0,0,0,1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_fill(image);<br>&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_surface_write_to_png<wbr>(surface, output_file);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_surface_destroy(surface);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_destroy(image);<br>&nbsp;&nbsp; }<br><br>&nbsp;&nbsp; int main(void)
<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; draw("one.png", 0, 0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; draw("two.png", 10, 10);<br>&nbsp;&nbsp; }<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>