No, test.png was created by Cairo, and then pixel data (which is premultiplied, as I am aware of) was copied to a GDI+ Bitmap and saved. I did this to get an idea of what Cairo was doing internally.<br><br>What I did with this output was tested this out in GIMP to see what effect this "brush" had; this output produced the same streaking in GIMP as it did in my test program, which leads me to believe that Cairo is using these premultiplied values during painting, which it should not be doing, as the 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 is my C# painting program, but all it is doing is using some of the basic stuff from Mono.Cairo to draw images onto the form. Here's what I am doing, in order:<br>
<br>1) Brush is selected from list; an empty Cairo ImageSurface is made to hold the brush image.<br>2) All of the pixels in the bitmap (acquired from DevIL) are iterated though.<br>3) The color values are multiplied by the color selected in the color 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 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, creating a SurfacePattern on the brush, setting its filter to Gaussian, creating a Matrix (for the Scale operation) and scaling it, setting the pattern's scale, creating context, translating to x/y of mouse, setting source to pattern, PaintWithAlpha on alpha set in the color picker.<br>
<br>I can wrap up my current C# work and put it online if that will work - I don't know if you can look at that at all, otherwise I'll put together a C application for it.<br><br>-P<br><br><div class="gmail_quote">
On Fri, Nov 12, 2010 at 4:07 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 7:24 AM, Paril <<a href="mailto:paril@alteredsoftworks.com">paril@alteredsoftworks.com</a>> wrote:<br>
> Hi there.<br>
><br>
> I'm writing a small app kind of like Paint, and using images as brushes;<br>
> these images are transparent PNGs with white as the brush color, and the<br>
> color is multiplied in the code to the color selected in a color picker,<br>
> with transparency being applied in PaintWithAlpha.<br>
><br>
> This problem is generic to cairo and not the API I'm using, hence why I'm<br>
> posting here.<br>
<br>
</div>Could you provide a small C program reproducing the problem?<br>
(The one using circle.png to generate test.png would be good)<br>
<div class="im"><br>
><br>
> Because cairo pre-multiplies the colors, it is obvious to expect that any<br>
> transparency would be multiplied into black; this makes sense to me,<br>
> however, with my understanding of pre-multiplied alpha, it is un-multiplied<br>
> by the rendering API so that it renders alpha properly. This appears not to<br>
> be the case, as all of my images render with an ugly black outline which<br>
> destroys alpha blending and creates "streaks" across the program.<br>
><br>
> Here is the image being used as a brush, and the image that is outputted by<br>
> Cairo after loading:<br>
> <a href="http://alteredsoftworks.com/cairo/circle.png" target="_blank">http://alteredsoftworks.com/cairo/circle.png</a><br>
> <a href="http://alteredsoftworks.com/cairo/test.png" target="_blank">http://alteredsoftworks.com/cairo/test.png</a><br>
><br>
> Does anyone have any experience with this sort of issue that they can tell<br>
> me what the problem is or how to combat it?<br>
<br>
</div>If you are accessing the image data directly, you have to handle it as<br>
premultiplied.<br>
<br>
In particular from the images you provided, my guess is that test.png was<br>
not generated using cairo png API (which unpremultiplies the data before<br>
storing it in the png file).<br>
<font color="#888888"><br>
Andrea<br>
</font></blockquote></div><br>