High quality, multi-platform pascal image interpolation (resizing/scaling) using TBitmap (VCL/FMX)
Supported sampling filters:
I was having a very hard time finding image scaling (resizing) code that is free to use, simple to integrate and high in quality. I finally managed to find usable code in mark mauder's vampyre imaging library, but it was wrapped in a lot of code that overly complicated the specific use function I needed.
I ended up modifying the code to make it simpler to use with both the VCL and FMX versions of TBitmap.
StretchResample(const SrcImage: TBitmap; SrcX, SrcY, SrcWidth,SrcHeight: LongInt; var DstImage: TBitmap; DstX, DstY, DstWidth, DstHeight: LongInt; Filter: TSamplingFilter; WrapEdges: Boolean = False); overload;
Example of resizing an image 50% :
ResizedImage.Width := SourceImage.Width div 2;
ResizedImage.Height := SourceImage.Height div 2;
StretchResample(SourceBitmap,0,0, MySourceBitmap.Width, MySourceBitmap.Height,ResizedBitmap,0,0,ResizedBitmap.Width,ResizedBitmap, sfLanczos,False);
For simplicity, I only supported 32bit (R/G/B/A) bitmap.
The code is pure pascal, there are no low level CPU-specific optimizations.
Based on the Vampyre Imaging Library by Marek Mauder
Modified for simplicity of use with TBitmap VCL/FMX classes by Yaron Gur