Very good and helpful article.
I found a minor bug in the getInstanceMethod() when it is called with higherQuality set to true with an image smaller or equal in size to the target size. When this happens, the method goes into a never ending loop.
There is a simple fix: force w and/or h to their respective target value when the situation is detected.
...
if (higherQuality) {
// Use multi-step technique: start with original size, then
// scale down in multiple passes with drawImage()
// until the target size is reached
w = img.getWidth();
if (w < targetWidth) {
w = targetWidth;
}
if (h < targetHeight) {
h = targetHeight;
}
h = img.getHeight();
} else {
....
|