Hi !
Featured games (88)
games approved by the League of Dukes
Games in Showcase (679)
Games in Android Showcase (194)
games submitted by our members
Games in WIP (734)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Smooth Image Scaling  (Read 3954 times)
0 Members and 1 Guest are viewing this topic.
Offline StumpyStrust
« Posted 2012-03-07 14:47:12 »

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?

Offline ra4king

JGO Kernel

Medals: 422
Projects: 3
Exp: 5 years

I'm the King!

« Reply #1 - Posted 2012-03-07 19:24:23 »

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.

Offline krasse
« Reply #2 - Posted 2012-03-07 19:28:45 »

This might help you:

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline StumpyStrust
« Reply #3 - Posted 2012-03-08 07:31:07 »

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

Offline krasse
« Reply #4 - Posted 2012-03-08 11:14:51 »

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)

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

DarkCart (27 views)
2016-05-29 02:30:33

Hydroque (40 views)
2016-05-26 14:45:46

Mac70 (53 views)
2016-05-24 21:16:33

theagentd (56 views)
2016-05-14 18:38:35

theagentd (89 views)
2016-05-10 22:37:41

theagentd (96 views)
2016-05-10 22:33:46

IanParcs (121 views)
2016-04-18 14:18:53

KaiHH (116 views)
2016-04-18 08:35:41

KaiHH (136 views)
2016-04-15 12:43:58

theagentd (143 views)
2016-04-14 02:16:17
FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17

List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!