Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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 2983 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: 350
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:

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

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.

1  
 drawImage(Image img, AffineTransform xform, ImageObserver obs)

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

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (37 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (27 views)
2014-10-15 16:18:58

TehJavaDev (52 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (77 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!