posted 7 years ago
Easiest is to start with outer loops that go from 0 to new width resp. new height. Then, for each value (x, y), determine the corresponding coordinates of the original image. Note that these mapped coordinates will be fractional values, say (x’ + alpha, y’ + beta).
Then determine what to do with these alpha and beta. You could discard these, use them to interpolate between surrounding pixels, et cetera.
An easier way (but probably also not allowed) is to create this new image, get its Graphics g, then simply draw the original image into it, using the appropriate draw scaling method.
(g,drawImage(oldImage, 0, 0, newWidth, newHeight, null)).
There are three kinds of actuaries: those who can count, and those who can't.