Here, I just threw this together very very quickly in C#; it CLEARLY shows the output "streaking" black transparent pixels down the purple brush stroke, when the expected output should show a complete purple circle with the same color on the inside of the capsule-like shape.<br>
<br><a href="http://alteredsoftworks.com/cairo/streaking.txt">http://alteredsoftworks.com/cairo/streaking.txt</a><br><br>It should be rather easy to convert to C/C++. I used no .NET-specific classes; DevIL for the image loading and Cairo for the drawing, just as I use in the actual program.<br>
<br>The reason I suspect premultiplication is because the only time these streaks can be created is when the background transparency is turned from white to black - which is done by multiplying the color values by their alpha. If all of the images' alpha and color values remain, when they are blended they should not create any streaks at all.<br>
<br>-P<br><br><div class="gmail_quote">On Fri, Nov 12, 2010 at 4:40 AM, Andrea Canciani <span dir="ltr"><<a href="mailto:ranma42@gmail.com">ranma42@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Fri, Nov 12, 2010 at 10:17 AM, Paril <<a href="mailto:paril@alteredsoftworks.com">paril@alteredsoftworks.com</a>> wrote:<br>
> No, test.png was created by Cairo, and then pixel data (which is<br>
> premultiplied, as I am aware of) was copied to a GDI+ Bitmap and saved. I<br>
> did this to get an idea of what Cairo was doing internally.<br>
<br>
</div>As you say test.png was not created with cairo png API (see<br>
<a href="http://cairographics.org/manual/cairo-PNG-Support.html" target="_blank">http://cairographics.org/manual/cairo-PNG-Support.html</a> )<br>
<br>
If GDI+ expects nonpremultiplied data, you have to unpremultiply it when<br>
copying to the GDI+ bitmap.<br>
Please check if unpremultiplying the data fixes your test image (and/or<br>
if saving test.png through cairo API makes it look correct).<br>
<br>
PS: it looks like GDI+ should be able to handle both premultiplied<br>
and nonpremultiplied data:<br>
<a href="http://msdn.microsoft.com/en-us/library/system.drawing.imaging.pixelformat.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/system.drawing.imaging.pixelformat.aspx</a><br>
<div class="im"><br>
><br>
> What I did with this output was tested this out in GIMP to see what effect<br>
> this "brush" had; this output produced the same streaking in GIMP as it did<br>
> in my test program, which leads me to believe that Cairo is using these<br>
> premultiplied values during painting, which it should not be doing, as the<br>
> white transparency is turning into black.<br>
><br>
> I don't have the time at the moment to put together a test app, all I have<br>
> is my C# painting program, but all it is doing is using some of the basic<br>
> stuff from Mono.Cairo to draw images onto the form. Here's what I am doing,<br>
> in order:<br>
><br>
> 1) Brush is selected from list; an empty Cairo ImageSurface is made to hold<br>
> the brush image.<br>
> 2) All of the pixels in the bitmap (acquired from DevIL) are iterated<br>
> though.<br>
> 3) The color values are multiplied by the color selected in the color<br>
> picker. The alpha from color picker is discarded, and only used later on.<br>
> 4) Since I am setting pixel data directly, I am multiplying the r, g and b<br>
> values by the alpha value.<br>
> 5) Data is set to the ARGB integer from said color.<br>
> 6) Drawing, by clicking on the form, is done by getting this brush image,<br>
> creating a SurfacePattern on the brush, setting its filter to Gaussian,<br>
> creating a Matrix (for the Scale operation) and scaling it, setting the<br>
> pattern's scale, creating context, translating to x/y of mouse, setting<br>
> source to pattern, PaintWithAlpha on alpha set in the color picker.<br>
<br>
</div>From your description, it is not clear to me if the problem you are seeing<br>
here is related with [non]premultiplication problems, but once you manage<br>
to fix the save-to-png routine, you should be able to check that the brush<br>
you have in step 5 is correct.<br>
<div class="im"><br>
><br>
> I can wrap up my current C# work and put it online if that will work - I<br>
> don't know if you can look at that at all, otherwise I'll put together a C<br>
> application for it.<br>
<br>
</div>Your description has been quite detailed, so I hope we can help you fix<br>
the problem without much additional work.<br>
<font color="#888888"><br>
Andrea<br>
</font></blockquote></div><br>