Transform

procedure Transform(Dst, Src: TCustomBitmap32; Transformation: TTransformation);

Description

Transform is responsible for arbitrary geometrical transformations of bitmaps or their fragments. The current version supports only affine and projective transformations.

The Transformation parameter is a reference to a descendant of an abstract TTransformation class. It specifies all necessary transformation parameters.

When Src.StretchFilter is different from sfNearest, Transform uses bilinear interpolation for magnification (along any axis) as for minification, it is not as accurate as StretchTransfer function. If you need better quality when minimizing the bitmaps, transform them into the temporary buffer so that there is no minification involved, then StretchTransfer to a final bitmap.

The function does not support spline interpolation, if Src.StretchFilter is sfSpline, Transform operates as if it were sfLinear.

There is an issue with antialiasing and edges. How to make them antialiased and still keep the performance? The solution implemented in Graphics32 is similar to the one used in OpenGL. You just have to provide the source bitmap (or its region) with transparent edges. In the original image, you’ll have to force the alpha channel on its edges to zeroes, for example, using the SetBorderTransparent method.

Remember, that color is interpolated as well, it means that for nice fadeout the color on the border should match the color of pixels lying next to the border.

In case the bitmap is transformed in dmOpaque mode, it might be better to keep the color on the edge close to the color of the background.

See Also

Examples, TCustomBitmap32, TCustomBitmap32.StretchFilter, StretchTransfer, TAffineTransformation, TProjectiveTransformation, TTransformation, SetBorderTransparent