[cairo] Premultiplied transparency causes streaks in images

Paril paril at alteredsoftworks.com
Fri Nov 12 04:41:04 PST 2010


I see, so it's the ImageSurface part.

I've been fighting this issue for a week now. I started out with GDI+, and
now Cairo, both of which have the same underlying problem (from what I
understand from what you're telling me): floating point pixel data.

Are there no other surfaces in Cairo's arsenal that I can use here? I see a
lot of other stuff like Xlib, Glitz, Xcb, does any of this give me anything
I could work with perhaps?

I'd look at GIMP but with such a large project I'm not exactly sure where
I'd look. There has to be something available to me that supports what I'm
looking to do..

On Fri, Nov 12, 2010 at 7:23 AM, Andrea Canciani <ranma42 at gmail.com> wrote:

> On Fri, Nov 12, 2010 at 12:54 PM, Paril <paril at alteredsoftworks.com>
> wrote:
> > The black halo isn't black in a colored image, I was talking about in the
> > white image, which I understand because of how premultiplication works (1
> 1
> > 1 1 * 1 1 1 0.5 = 0.5 0.5 0.5 0.5); with the different colors it changes
> > around, but yes, you are right, it's more like a multicolored halo.
> >
> > I get what you mean with the error accumulation, but what else can I do
> > here? There's no Cairo function, that I can tell, to use SetSourceColor
> when
> > SetSource on a pattern is used, hence why I do the color stuff manually,
> and
> > I still have to multiply the values to get the bitmap together for Cairo
> to
> > use properly. The _fixed.txt you had attached before seemed to just
> lighten
> > the transparency and make it less visible, but the streaks are still
> > definitely there.
> >
> > Your explanation of errors makes complete sense to me because when I look
> at
> > it, the streaks barely occur when the color values are 0, 0.5 or 1; any
> > value in-between and you can see the streaks on a huge scale, but with
> those
> > three values you see maybe one or two points off the color.
> >
> > Cairo only supports integral colors, so there will be rounding errors
> with
> > all of this multiplication... do you have any ideas on what I can do?
>
> Actually cairo supports floating points colors, but the image backend
> (which
> composites images using pixman) restricts you to integers. In theory it
> would
> be possible to use floating point formats (for example on macosx you could
> create a cairo-quartz surface that stores color information in floats).
>
> I'm currently working on supporting colorspaces in cairo and pixman
> and a side-project
> includes extending the supported formats, but right now my code is
> experimental
> (and, at least in some parts, broken) and will anyway take some time
> to get it into
> the projects, so I guess that relying on cairo support for floating
> point compositing
> is not an option right now.
>
> I think that (unless you are willing to do the compositing yourself),
> you might want to
> look at how gimp (or some other open source project) handles this issue.
>
> Andrea
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20101112/c7aac34f/attachment.html>


More information about the cairo mailing list