I’m trying to perform a simple zoom pan on a picture.
Let’s say I have a picture 640x800, I’m trying to zoom it to the whole screen width (1920 for my screen), and slowly pan it vertically.
Currently, I’m doing this:
float width = (float)getWidth(), height = (float)getHeight(); float iw = (float)currentImage->getWidth(), ih = (float)currentImage->getHeight(); float bigH = ih * width / iw; // pos is a number going from 0 (top of picture), to 1 (bottom of picture). g.drawImageTransformed(currentImage, currentImage->getBounds(), AffineTransform::scale(width / iw, width / iw).translated(0, -(bigH - height) * (float)pos));
I call this code repeatively, but it’s so slow to perform (in release mode, with image subsampling set to lowest, this takes 160ms on my Core2Duo, thus breaking any smooth effect).
How could I speed this up (I can’t use OpenGL) ?