resize wtf

I get amused whenever I see another open-coded version of this in our codebase, a method for determining the resolution of a scaled-down image while maintaining aspect ratio:


while (x > targetx || y > targety) {
x *= 0.99;
y *= 0.99;
}

It’s pretty easy to discern that it will take a lot of iterations to accomplish this task. In fact I put it around 250 * log (x/x') where x’ is the target width. That’s maybe as many as 2000 FP multiplies depending on the difference in sizes between source and target image.

I guess computing the smallest scale factor and using it once was just too hard…