[cairo] defining CLAMP extend mode
otaylor at redhat.com
Sat Oct 21 18:39:32 PDT 2006
On Sat, 2006-10-21 at 14:27 -0700, Vladimir Vukicevic wrote:
> A while back (I believe on IRC), we discussed defining a new extend mode
> that would behave a bit more like people expect. That is, if the sample
> point is within the bounds of the source image, it would be clamped to
> its bounds; if outside, then it would be transparent. Right now, there
> is a smooth transition between the two areas, which leads to artifacts
> when upscaling.
Your formulation doesn't make it at all easy to get the
antialiasing right at the boundaries... say I want to rotate an image
by 45 degrees and draw the upper left quadrant ... if use a fill()
a rectangle that is the upper left corner, the upper pixels will get
That's assuming that you are implying that partially filling such an
image would anti-alias pixels the source pixels that are only
*partially* from the source ... not an easy job to implement to begin
> EXTEND_PAD can help with this, but only if the destination is clipped to
> the actual area of the transformed source image -- that is, calling
> cairo_paint() with no clip and an image source with EXTEND_PAD would
> cause bleed to the left and bottom.
Why would you do that? My expectation is that if you want a "scaled
photo" you'd fill() the transformed source, not paint(). If you define
the sampling from the source image right, PAD plus filling (or
clipping to) the transformed source should give optimal results.
There are obvious some application where this requires a bit of
extra work, but it shouldn't generally be too onerous.
And why is the bleed only to the left and bottom? (left and bottom?
that's a weird combination) I'm probably not understanding the problem
you are referring to to begin with.
> CAIRO_EXTEND_PAD is also not
> implemented for image surfaces in pixman, so this may be moot anyway.
Well, that needs to be fixed!
More information about the cairo