[cairo] defining CLAMP extend mode

Bill Spitzak spitzak at d2.com
Mon Oct 23 15:50:28 PDT 2006


I might have the terms wrong. By "EXTEND_PAD" I mean the filtering is 
done such that when requesting a pixel to be filtered, the pixel 
coordinates are clamped to the source rectangle.

Another way of looking at it is imagining the image has the rows and 
columns of pixels on the edge repeat to infinity, producing "stripes" at 
right angles to the image edge, and the corners are filled to infinity 
with the value of the corner pixel. This new source image is used for 
the filtering.

This is entirely independent of figuring out the antialised coverage of 
the resulting output pixel. This needs to be done by multiplying the 
filtered image pixel by a correctly antialiased rectangle. Don't be 
tempted to think that the clamping and the antialiasing use the same 
code, they don't, because of math inaccuracy, there very well may be 
pixels that are 100% opaque but have clamped samples, and pixels that 
have no clamped samples but are partially transparent.

Bill Spitzak wrote:
> I'm quite certain the only working implementation is equivalent to doing 
> EXTEND_PAD, after first clipping to a (antialiased) rectangle that is 
> the source image boundary transformed to the destination. Don't think of 
> it as clamping, the actual sampling *is* EXTEND_PAD and is calculated 
> entirely seperately from the clip.


More information about the cairo mailing list