Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
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  
  Best Method For Scaling Image Resources/Sprites  (Read 1331 times)
0 Members and 1 Guest are viewing this topic.
Offline ghostsoldier23

Junior Devvie


Medals: 1



« Posted 2013-01-10 04:28:35 »

My monitor is 1920x1080, so everything I create on it will be how it looks on a 1920x1080 monitor.

This isn't, however, necessarily the "best" or highest resolution.

Is it still best then to scale everything to the user's resolution from my own?  And should scaling be done only down, or up as well?

How to create the graphics for a game has always been my biggest issue mainly for this reason.

If you are simply going to scale everything up or down, what is the best method to doing this?  AffineTransform or scaling each image individually when it's loaded?
Offline GabrielBailey74
« Reply #1 - Posted 2013-01-10 05:20:56 »

I could be wrong here Emo, are you familiar with Java's 'DisplayMode' class?
After you've initialized your 'window' you can attempt to set the users GraphicsDevice settings to your resolution likings.
^ Hope that makes sense.

1  
2  
3  
4  
5  
/* Initialize Window Above Here */
final int width = 640;
final int height = 480;
GraphicsDevice userGraphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
userGraphicsDevice.setDisplayMode(new DisplayMode(width, height, DisplayMode.BIT_DEPTH_MULTI, DisplayMode.REFRESH_RATE_UNKNOWN));

Pretty sure there's a way to do this without having to set a window to full screen.

Hope it helps some.

Offline Danny02
« Reply #2 - Posted 2013-01-10 12:56:00 »

This is the best way to scale a Image in Java(you can change of course some of the parameters and so on) ->
https://github.com/Danny02/DarwinsBox/blob/master/Util/src/main/java/darwin/util/image/ImageUtil2.java

Scaling images at startup to the desired size is always good, because you can use better scaling functions.
There is a bunch of functions which can be used to scale an image, from fast and low quality to slow and high quality.

So it is of course best to not need any scaling at run-time at all. So scale all your images with the most expensive functions at startup to get the best visuals.
There are of course always some corner cases for which this rule doesn't fully apply.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ReBirth
« Reply #3 - Posted 2013-01-10 12:58:40 »

When I dev an android game, I'll whip my artist telling all image should be based on S3 resolution (which already big enough for phone) so all I do is scaling down to keep the quality.

So yes, +1 for high images.

Offline ghostsoldier23

Junior Devvie


Medals: 1



« Reply #4 - Posted 2013-01-10 20:02:04 »

This is the best way to scale a Image in Java(you can change of course some of the parameters and so on) ->
https://github.com/Danny02/DarwinsBox/blob/master/Util/src/main/java/darwin/util/image/ImageUtil2.java

What is the author doing with the "accWidth" and "accHeight" variables in this code exactly?

What is the point of the loop and the Math.max call?
Offline Danny02
« Reply #5 - Posted 2013-01-10 20:17:29 »

the point of this is to not down-scale an image more then half of its size, because this can causes aliasing.
Offline ghostsoldier23

Junior Devvie


Medals: 1



« Reply #6 - Posted 2013-01-10 21:31:33 »

the point of this is to not down-scale an image more then half of its size, because this can causes aliasing.

Why is there a while loop?  It seems to me that those two variables will never be changed from their initial values.
Offline Danny02
« Reply #7 - Posted 2013-01-11 08:02:41 »

take another look, each time the loop is called the image size to which to scale is halfed. (this is only done if the highquality flag is set)
Offline nsigma
« Reply #8 - Posted 2013-01-11 09:27:00 »

take another look, each time the loop is called the image size to which to scale is halfed. (this is only done if the highquality flag is set)

I've only seen that approach done with bilinear scaling, not bicubic - called progressive bilinear scaling.  The halving then makes sense because that's the threshold where bilinear stops sampling a pixel.  Does bicubic offer any advantage?  Could it actually be less accurate because it's sampling outside the area?

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
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.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (40 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (47 views)
2014-11-29 21:32:03

toopeicgaming1999 (114 views)
2014-11-26 15:22:04

toopeicgaming1999 (102 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

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
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!