Hi,
I want to create down-scaled Bitmaps ( original Bitmap loaded from asset) with high quality comparable to the quality of bitmaps scaled with professional software like Paint.net (in Paint.NET the algorithm for scaling is choosen in a field called Interpolation. The highest setting uses supersampling)?
I understand how to implement supersampling for anti-aliasing. For anti-aliasing-purpose the original image is rendered in higher resolution and then gets downsampled. For Example to get a target image of 100x100 you would render the scene to 200x200 and then downsampling it with a 2x2 grid.
But, how the algorithm can handle downsampling from let's say 400x400 to 175x175 for scaling-purpose. The grid must be ~ 2.285x2.285 in this case. So how can supersampling be implemented for scaling-purpose?
I tried this code:
public static Bitmap downscaleBitmap(Bitmap src, int targetWidth, int targetHeight, int off){
float r = (src.getWidth()-off)/(float)targetWidth;
float s = (src.getHeight()-off)/(float)targetHeight;
The following image shows the same 100x100 bitmap scaled to 54x54. The left one is scaled by Paint.Net and the right one by my algorithm. Doesn't look good for my implementation... How can I improve my code?
thx & regards
PS: I work with Java on Android, but I think my question is more generel then android-specific..
EDIT:
I changed my code + added a bit blur to the bitmap before scaling like amnon.owed suggests. The result is pretty good on my smartphone. Even a bit better then the "Paint.Net-version" !