<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>You can see the image with black pixel at this url:</p>
<p><a class="moz-txt-link-freetext" href="https://ibb.co/gbuXrU">https://ibb.co/gbuXrU</a></p>
<p><br>
</p>
<p>This is done using glBlendFunc(GL_SRC_ALPHA,
GL_ONE_MINUS_SRC_ALPHA);</p>
<p>Instead, using GL_ONE the image is showing perfectly! <br>
</p>
<p><br>
</p>
<p>Thank you very much for your help.</p>
<p>Lorenzo<br>
</p>
<br>
<div class="moz-cite-prefix">On 08/09/2018 05:55 PM, Bill Spitzak
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAL-8oAh6d+jSrOc_rn9mfEGxMgoBKMLrmF4Xw7HzQ7psXtC-gw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div dir="ltr">Though I would not expect it to look as bad as
described, you want the first argument to be GL_ONE, not
GL_SRC_ALPHA.
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Aug 9, 2018 at 6:07 AM, Lorenzo
<span dir="ltr"><<a href="mailto:gatti88@libero.it"
target="_blank" moz-do-not-send="true">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">
<div text="#000000" bgcolor="#FFFFFF">
<p>Sorry, by i already have the BlendFunc method.</p>
<p>I initialize my opengl system with this code:</p>
<p>glViewport(0, 0, drm->rect()->w,
drm->rect()->h);<br>
glDisable(GL_CULL_FACE);<br>
glEnable(GL_LESS);<br>
glEnable(GL_BLEND);<br>
glEnable(GL_TEXTURE_2D);<br>
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);</p>
<p><br>
</p>
<p>Lorenzo.<br>
</p>
<div>
<div class="h5"> <br>
<div class="m_-361436772985432152moz-cite-prefix">On
08/08/2018 08:00 PM, Bill Spitzak wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>glBlendFunc(GL_SRC_ALPHA,
GL_ONE_MINUS_SRC_ALPHA);</div>
<div><br>
</div>
<div>Sorry, I managed to cut & paste the one
example I had that did not say "ALPHA"</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Aug 8, 2018 at
10:59 AM, Bill Spitzak <span dir="ltr"><<a
href="mailto:spitzak@gmail.com"
target="_blank" moz-do-not-send="true">spitzak@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<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="m_-361436772985432152HOEnZb">
<div class="m_-361436772985432152h5">
<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"
moz-do-not-send="true">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="m_-361436772985432152m_-5063440743205944044HOEnZb"><font
color="#888888"><br>
<br>
<br>
<br>
<br>
<br>
-- <br>
cairo mailing list<br>
<a
href="mailto:cairo@cairographics.org"
target="_blank"
moz-do-not-send="true">cairo@cairographics.org</a><br>
<a
href="https://lists.cairographics.org/mailman/listinfo/cairo"
rel="noreferrer"
target="_blank"
moz-do-not-send="true">https://lists.cairographics.or<wbr>g/mailman/listinfo/cairo</a></font></span></blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>