Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 5234 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: 508
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  

EgonOlsen (45 views)
2018-06-10 19:43:48

EgonOlsen (25 views)
2018-06-10 19:43:44

EgonOlsen (47 views)
2018-06-10 19:43:20

DesertCoockie (202 views)
2018-05-13 18:23:11

nelsongames (127 views)
2018-04-24 18:15:36

nelsongames (126 views)
2018-04-24 18:14:32

ivj94 (867 views)
2018-03-24 14:47:39

ivj94 (128 views)
2018-03-24 14:46:31

ivj94 (771 views)
2018-03-24 14:43:53

Solater (143 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!