TStretchFilter

Graphics32

TStretchFilter

type TStretchFilter = (sfNearest, sfDraft, sfLinear, sfCosine, sfSpline, sfLanczos, sfMitchell);

Description

When the bitmap is scaled, these filters control how the colors are interpolated:

  • sfNearest is the fastest filter, although the quality of the stretched image is fair.
  • sfDraft is a complex resampler, meaning that it uses several different methods. For downsampling it uses row-column zoneshifting to preserve more details than sfNearest, however the quality is not as good as sfLinear. For upsampling it uses a linear interpolation method that may compromise details - this happens if both downsampling and upsampling is needed. sfDraft is ideal for preview fields and thumbnails. Please note, that the algorithm is not pixel-perfect, that why using a custom cliprect might result in a so called jitter-effect.
  • sfLinear is several times slower, but it produces more decent results in most cases.
  • sfCosine is almost equally fast as sfLinear, but it uses cosine interpolation, which produces a sharper image.
  • sfSpline is an approximation of spline interpolation, for some applications its result may be too smooth and blurry, but when using with large magnification factors, it usually yields better image compared to sfLinear.
  • sfLanczos generally produces the sharpest image (especially when downsampling), however sometimes can produce excessive "ringing" effect - this is the slowest filter.
  • sfMitchell is often considered as one of the best filters for enlarging images; generally not as sharp as Lanczos.

In some functions filters above sfLinear may not be applicable (for example in Transform), in this case the filter value will be substituted with sfLinear.

 

See Also

TBitmap32.StretchFilter, StretchTransfer