I have been using Youlean’s branch of IPlug1 for resizable graphics. Through some experimentation, I found a way to greatly improve bitmap resizing. The original resizing was done with bilinear resampling in IGraphics.cpp. The bitmaps can get fuzzy very quickly, even when close to their original size.
I found Aleksey Vaneev (from Voxengo) has created a library for resampling images. It is very easy to replace within IGraphics. The repo is located at
https://github.com/avaneev/avir. It includes 5 header files, but I think only one is needed for simple resizing.
The main resizing is handled by avir::CImageResizer<>; however, after emailing Aleksey, he suggested to use avir::CLancIR. CLancIR produces great resizing and is very fast for good realtime results. I did use CImageResizer initially, and it would work in realtime, but CLancIR is much smoother.
So, here are the changes I added to IGraphics.h/cpp to use the different resizing. Please note, this is not the prettiest way of adding the code. You could easily create different functions and keep the bilinear resampling if you wanted to. I did this as a test and decided to keep everything within the original ResizeBilinear() function.
In IGraphics.h, add the header file wherever you same the lancir.h file within your project. Example,
Code:
#include "../../avir/lancir.h"
In IGraphics.cpp, comment out the entire body of the ResizeBilinear() function. In it’s place, add the following as the new ResizeBilinear() function. I have added comments to explain things.
Code:
//declare the resizer class one time, but this could be moved as a private member in IGraphics.h
static avir::CLancIR ImageResizer;
//you could also try other resizers like the following, but CLancIR appears to be much faster
//If you try the following, replace the lancir.h include with avir.h
//static avir::CImageResizer<> ImageResizer(8, 0, avir::CImageResizerParamsHigh());
//since ints are used, some problems with rounding can occur. To help, calculate ratio with the largest
//between width and height.
double ratio = 1.;
if(h1 > w1) ratio = (double)h1 / (double)h2;
else ratio = (double)w1 / (double)w2;
ImageResizer.resizeImage((uint8_t *)input, sourceRowSpan, h1, 0, (uint8_t*)out, destinationRowSpan, h2, 4, ratio);