Smooth Image Scaling

So in opengl you don’t have this problem.

When you draw an image in java 2D you use ints. But if you want an image to scale up/down at a rate less than 1 you start to get a stutter effect same with object movement speeds being less than 1.

g2d.drawImage(myImage, x1, y1, x2, y2, observer)

When I draw an Image base on a point I take the current size of the image and (say 64x64) divide it by 2, subtract them from my x/y cords. This gives me the location for the first point. The second points are the size of the image you want to draw or the height and width.
This makes it so the original point is in the center. (collisions look normal)

Unfortunately this gives a back stutter effect to the scaling up/down images.

Any way to make it not have the stutter?

Could you be a bit more descriptive? I don’t see a stutter when drawing scaled images, unless you have a crappy graphics card/CPU.

This might help you:

http://docs.oracle.com/javase/tutorial/2d/text/renderinghints.html

When you draw an image that is scaled you don;t get a stutter. I is just drawn but when you have the images size increasing gradually over time at a rate less then 1 (a double not an int)
Do to casting to an int you start to get a stutter as the image grows from say 4x4 to 16x16

It is probably better to use an affine transform to perform the gradual scaling. Then you can have floating point scaling that might look better for small images.


 drawImage(Image img, AffineTransform xform, ImageObserver obs)