Support
SiteLinks |
FAQ /
Resampling<< Image format related | Frequently asked questions | Miscellaneous >> 1. Where did the stretch filters go in Graphics32 1.8?Stretch filters have been replaced with resamplers in Graphics32 1.8. This means that you can't switch between different resampling methods simply by changing the StretchFilter property of a TBitmap32 instance. The introduction of resampler classes was an attempt to make Graphics32 more flexible and to allow custom resampling methods to be implemented without patching the existing codebase. 2. Can I still use stretch filters in Graphics32 1.8?Yes, by defining the conditional symbol $DEPRECATEDMODE in the file GR32.INC, stretch filters may still be used. However, from Graphics32 1.8 this is considered obsolete and it may not be supported in future versions. 3. What is a resampler and how do I use it?A resampler is a special class derived from TCustomResampler. It provides a method for reconstructing pixels when an image is scaled. Each TBitmap32 object has its own dedicated resampler, accessible through the Resampler property. Currently four different resampler classes have been implemented in Graphics32:
As can be seen from the above table, there is always a trade-off between quality and performance when choosing a resampler. While TNearestResampler is fast, it gives a very poor result. Contrary, TKernelResampler gives a high quality result at the expense of a degraded performance. Example 1: Given a TBitmap32 object TDraftResampler.Create(B); Example 2: Suppose that we want to resize the source bitmap procedure DrawSrcToDst(Src, Dst: TBitmap32); var R: TKernelResampler; begin R := TKernelResampler.Create(Src); R.Kernel := TLanczosKernel.Create; Dst.Draw(Dst.BoundsRect, Src.BoundsRect, Src); end; |