<div dir="ltr">You have to change the OpenGL compositing to over the premultiplied image. I think glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR) is what you need.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 8, 2018 at 8:16 AM, Lorenzo <span dir="ltr"><<a href="mailto:gatti88@libero.it" target="_blank">gatti88@libero.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
i have a problem with the creation of a rounded rectangle with cairo.<br>
<br>
Environment info:<br>
<br>
cairo version: 1.14.8-1<br>
<br>
OS: linux<br>
<br>
<br>
A linux client creates a rounded rectangle with the following code:<br>
<br>
        let x = 0.0<br>
        let y = 0.0<br>
        let w = Double(size.w)<br>
        let h = Double(size.h)<br>
        let r = 20.0<br>
<br>
        logger.verbose("rounded rectangle x=\(x),y=\(y),w=\(w),h=\(h),r=<wbr>\(r)")<br>
<br>
        cairo_move_to(context, x, y + r)<br>
        cairo_arc(context, x + r, y + r, r, Double.pi, -Double.pi / 2.0)<br>
        cairo_line_to(context, x + w - r, y)<br>
        cairo_arc(context, x + w - r, y + r, r, -Double.pi / 2.0, 0.0)<br>
        cairo_line_to(context, x + w, y + h - r)<br>
        cairo_arc(context, x + w - r, y + h - r, r, 0.0, Double.pi / 2.0)<br>
        cairo_line_to(context, x + r, y + h)<br>
        cairo_arc(context, x + r, y + h - r, r, Double.pi / 2.0, Double.pi)<br>
        cairo_close_path(context)<br>
<br>
<br>
        cairo_set_source_rgba(context, cl.red, cl.green, cl.blue, cl.alpha);<br>
        cairo_fill(context)<br>
<br>
<br>
After the surface fill  i have 2 different operations to be performed:<br>
<br>
    - write the png on the disk using "cairo_surface_write_to_png(su<wbr>rface, "testcairo.png")"<br>
<br>
    - display the png with opengl es 3.0 as a texture (done by copy the surface raw bytes with cairo_image_surface_get_data(s<wbr>urface)<br>
<br>
      in a shared memory used by the opengl server program)<br>
<br>
<br>
Save the image on disk is ok, the image is good.<br>
<br>
Display the image as a texture with opengl results in an ugly image: corners have some black pixels around them.<br>
<br>
Why this difference?<br>
<br>
<br>
I have done some checks:<br>
<br>
- data obtained with cairo_image_surface_get_data are the same that the graphics server loads from the shared memory (checked PixelxPixel) so the data transfer don't is the problem (checked also any signed/unsigned byte conversion)<br>
<br>
- loading the disk png as a texture instead of loading data from the shared memory results in a good image with no problems.<br>
<br>
<br>
My opinion is that the cairo_surface_write_to_png performs an antialiasing algorithm and accessing raw data bypass it taking the original image.<br>
<br>
<br>
Is my opinion correct? If yes, any advice to solve the problem?<br>
<br>
<br>
Regards,<br>
<br>
Lorenzo.<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
<br>
<br>
<br>
-- <br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org" target="_blank">cairo@cairographics.org</a><br>
<a href="https://lists.cairographics.org/mailman/listinfo/cairo" rel="noreferrer" target="_blank">https://lists.cairographics.or<wbr>g/mailman/listinfo/cairo</a></font></span></blockquote></div><br></div>