<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Dear Experts, <div>I am working toward implementing Cairo in GrADS, an open source program for the analysis and display of meteorological data. My use of cairo is fairly basic. In a test program, I am drawing two adjacent triangles with transparency set to 0.50, writing out .pdf and .png formats. A faint line shows up along the common boundary of the two triangles (i.e., along the diagonal of what should be a solid rectangle). Disabling anti-aliasing makes the line go away in the .png file, but it persists in the .pdf. What is causing this and is there a remedy? </div><div><br></div><div>My test program looks like this:</div><div><br></div><div><div><font class="Apple-style-span" face="Courier" size="2">#include <stdio.h></font></div><div><font class="Apple-style-span" face="Courier" size="2">#include <stdlib.h></font></div><div><font class="Apple-style-span" face="Courier" size="2">#include <cairo.h></font></div><div><font class="Apple-style-span" face="Courier" size="2">#include <cairo-pdf.h></font></div><div><font class="Apple-style-span" face="Courier" size="2"><br></font></div><div><font class="Apple-style-span" face="Courier" size="2">int main (int argc, char *argv[]) {</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_surface_t *surface=NULL;</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_t *cr;</font></div><div><font class="Apple-style-span" face="Courier" size="2"> int winx,winy;</font></div><div><font class="Apple-style-span" face="Courier" size="2"><br></font></div><div><font class="Apple-style-span" face="Courier" size="2"> winx = winy = 200; </font></div><div><font class="Apple-style-span" face="Courier" size="2"> surface = cairo_pdf_surface_create ("hello.pdf",winx,winy);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cr = cairo_create (surface);</font></div><div><font class="Apple-style-span" face="Courier" size="2"><br></font></div><div><font class="Apple-style-span" face="Courier" size="2"> /* fill white background */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_set_source_rgb(cr,1,1,1);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_rectangle(cr,0,0,winx,winy);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_fill(cr);</font></div><div><font class="Apple-style-span" face="Courier" size="2"><br></font></div><div><font class="Apple-style-span" face="Courier" size="2"> /* two adjacent semi-transparent filled triangles with anti-aliasiang turned off */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_set_antialias(cr,CAIRO_ANTIALIAS_NONE); </font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_set_source_rgb (cr, 0, 0, 0);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_move_to (cr, 20, 15);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_set_font_size (cr, 10);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_show_text (cr, "without anti-alias");</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_set_source_rgba (cr, 0, 0, 0, 0.5);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_move_to(cr, 20, 20); /* ul */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_line_to(cr, 120, 20); /* ur */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_line_to(cr, 120, 90); /* lr */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_fill(cr);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_move_to(cr, 20, 20); /* ul */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_line_to(cr, 20, 90); /* ll */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_line_to(cr, 120, 90); /* lr */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_fill(cr);</font></div><div><font class="Apple-style-span" face="Courier" size="2"><br></font></div><div><font class="Apple-style-span" face="Courier" size="2"> /* two adjacent semi-transparent filled triangles with anti-aliasiang turned on */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_set_antialias(cr,CAIRO_ANTIALIAS_DEFAULT); </font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_set_source_rgb (cr, 0, 0, 0);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_move_to (cr, 20, 115);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_set_font_size (cr, 10);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_show_text (cr, "with anti-alias");</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_set_source_rgba (cr, 0, 0, 0, 0.5);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_move_to(cr, 20, 120); /* ul */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_line_to(cr, 120, 120); /* ur */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_line_to(cr, 120, 190); /* lr */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_fill(cr);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_move_to(cr, 20, 120); /* ul */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_line_to(cr, 20, 190); /* ll */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_line_to(cr, 120, 190); /* lr */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_fill(cr);</font></div><div><font class="Apple-style-span" face="Courier" size="2"><br></font></div><div><font class="Apple-style-span" face="Courier" size="2"> /* finish up */</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_surface_show_page (surface);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_destroy (cr);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_surface_finish (surface);</font></div><div><font class="Apple-style-span" face="Courier" size="2"> cairo_surface_destroy (surface);</font></div><div><font class="Apple-style-span" face="Courier" size="2"><br></font></div><div><font class="Apple-style-span" face="Courier" size="2"> return 0;</font></div><div><font class="Apple-style-span" face="Courier" size="2">}</font></div></div><div><br></div><div>The .pdf and .png output are here:</div><div><a href="http://iges.org/jma/hello.pdf">http://iges.org/jma/hello.pdf</a></div><div><a href="http://iges.org/jma/hello.png">http://iges.org/jma/hello.png</a></div><div><br></div><div>I'm working with the macports install of cairo for Mac OSX Lion, and I am using Preview and Adobe Acrobat Professional to display the .pdf file -- the diagonal line is visible in both, but it is lighter than the rest of the rectangle in Preview and darker in Acrobat. I was unable to create a trace file; I got this message when running cairo-trace:</div><div><div><font class="Apple-style-span" face="Courier" size="2">Assertion failed: (cairo_pdf_surface_create_real != NULL), function cairo_pdf_surface_create, file trace.c, line 4310.</font></div><div><font class="Apple-style-span" face="Courier" size="2">/opt/local/bin/cairo-trace: line 136: 82232 Abort trap: 6 (core dumped) CAIRO_TRACE_FD=3 "$@" 3>&1 > /dev/null</font></div><div><br></div><div>Many thanks for any guidance you can provide. </div><div>--Jennifer</div><div><br></div><div apple-content-edited="true">
<div style="font-size: 12px; ">--</div><div style="font-size: 12px; ">Jennifer M. Adams</div><div style="font-size: 12px; ">IGES/COLA</div><div style="font-size: 12px; ">4041 Powder Mill Road, Suite 302</div><div style="font-size: 12px; ">Calverton, MD 20705</div><div style="font-size: 12px; "><a href="mailto:jma@cola.iges.org">jma@cola.iges.org</a></div><div style="font-size: 12px; "><br class="khtml-block-placeholder"></div><span class="Apple-style-span" style="font-size: 12px; "><br class="Apple-interchange-newline"></span>
</div>
<br></div></body></html>