Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
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  
  Quality of AffineTransform.rotate  (Read 6694 times)
0 Members and 1 Guest are viewing this topic.
Offline kuroyan

Senior Newbie





« Posted 2007-02-21 19:15:12 »

I want to draw a BufferedImage in an animation und rotate the original image each frame around an
increasing angle. Although I turned on Graphics2D-Antialias, I always end up with something like that -.-



Anyone know how to increase the rotation quality?
Offline Kova

Senior Devvie





« Reply #1 - Posted 2007-02-21 23:09:35 »

I want to draw a BufferedImage in an animation und rotate the original image each frame around an
increasing angle. Although I turned on Graphics2D-Antialias, I always end up with something like that -.-

hehe, if anybody wanted to know how to spot a german in forums he got his anwser Smiley

about rotation, I don't know how to (or if you can) increase quality, somebody else will help you with that, but I know that rotation in Java2d is all done in software, at least on windows, nothing hardware accelerated. Very dissappointing for game devs using java2d.
Offline CommanderKeith
« Reply #2 - Posted 2007-02-22 02:28:03 »

Take a look at RenderingHints, it has a whole bunch of options to do that stuff:

http://java.sun.com/javase/6/docs/api/java/awt/RenderingHints.html#KEY_INTERPOLATION

Keith

PS: I'm pretty sure that the OGL pipeline does hardware rotation.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kuroyan

Senior Newbie





« Reply #3 - Posted 2007-02-22 12:19:31 »

hehe, if anybody wanted to know how to spot a german in forums he got his anwser Smiley

Austrian, not German Smiley

@Kova: thx for that, I totally forgot that Smiley
And is there any easier way to rotate and scale images with higher performance than
using JOGL? Maybe activating -Dsun.java2d.opengl? Or are there other APIs than let you
do 2-dimensional image transformations, that are easier to handle?
Offline Linuxhippy

Senior Devvie


Medals: 1


Java games rock!


« Reply #4 - Posted 2007-02-22 13:52:26 »

yes, java2d's opengl backend also accalerates rotation.

greetings from austria (too), lg Clemens
Offline Kova

Senior Devvie





« Reply #5 - Posted 2007-02-22 15:11:02 »

opengl pipeline in my experience is very buggy... I mean it's not Java, it's ATI (and maybe nvidia?) drivers. Simple swing application didn't work with my radeon x800, like jbuttons and half of stuff didn't or were wrongly rendered. I don't know how situation is on other platforms.
Offline campbell

Junior Devvie




Java games rock!


« Reply #6 - Posted 2007-02-23 01:42:21 »

I want to draw a BufferedImage in an animation und rotate the original image each frame around an
increasing angle. Although I turned on Graphics2D-Antialias, I always end up with something like that -.-

Could you please post your source image (unrotated) and then take a screenshot of what it looks like rotated?  Also post the relevant source code.  It's hard to see what you're doing from just this one image.

Chris
Offline kuroyan

Senior Newbie





« Reply #7 - Posted 2007-02-23 15:20:12 »

Yes ok, but with the KeyInterpolation set to Bileanar it works just fine Smiley
The original image:


The rotated image without bilieaner interpolation:


The rotated image with bilieaner interpolation (and another background):


And the source code for transforming and drawing the image:
1  
2  
3  
4  
5  
6  
7  
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
      RenderingHints.VALUE_INTERPOLATION_BILINEAR);
AffineTransform aft = new AffineTransform();
aft.translate(90 - img.getWidth() / 2, 90 - img.getHeight() / 2);
aft.rotate(Math.toRadians(degree), img.getWidth() / 2,
      img.getHeight() / 2);
g2.drawImage(img, aft, this);
Offline campbell

Junior Devvie




Java games rock!


« Reply #8 - Posted 2007-02-24 03:12:41 »

Yes ok, but with the KeyInterpolation set to Bileanar it works just fine Smiley

This is weird.  Which JDK release are you running on?  Which OS?  Are you passing any system properties such as -Dsun.java2d.d3d=true or -Dsun.java2d.noddraw=true?

If you're not using JDK 6, please try that release and see if you get different behavior.  (We reimplemented our transform loops in JDK 6 so that they're faster and more direct.)

Chris
Offline kuroyan

Senior Newbie





« Reply #9 - Posted 2007-02-24 08:35:01 »

I am using JDK 6 build 105 and only use "-Dsun.java2d.opengl=true" as VM arguments.
And I don't quite get what is so weird about my samples? As far as I see everything works just fine...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline campbell

Junior Devvie




Java games rock!


« Reply #10 - Posted 2007-02-25 09:21:31 »

I am using JDK 6 build 105 and only use "-Dsun.java2d.opengl=true" as VM arguments.

Okay.  This could be a bug in the OGL pipeline then.  Which video board are you using, and which driver version?  What kind of source image are you transforming (i.e. is it a BufferedImage or a VolatileImage)?

I assume that you don't see this bug if you don't pass -Dsun.java2d.opengl=true on the command line?

Quote
And I don't quite get what is so weird about my samples? As far as I see everything works just fine...

Huh?  The whole point of this thread is that rotation is producing blocky (buggy) images; isn't that why you started the thread in the first place?  Your second screenshot is clearly showing a bug; it's not what NEAREST_NEIGHBOR is supposed to look like.  That's what's weird.

Chris
Offline kuroyan

Senior Newbie





« Reply #11 - Posted 2007-02-25 09:54:27 »

@campbell: uhm yes, I meant everything works just fine with Bilieanar interpolation^^

I'm not sure what's a video board in german, so I'll post a screenshot of the dxdiag and hope it will help...

http://img214.imageshack.us/img214/9461/dxdiagscreenshotsg7.jpg
Offline Kova

Senior Devvie





« Reply #12 - Posted 2007-02-25 10:26:02 »

but still, why not fully answer campbell's question?

are you seeing the bug if you don't use -Dsun.java2d.opengl=true ?
is img BufferedImage or VolatileImage?
Offline kuroyan

Senior Newbie





« Reply #13 - Posted 2007-02-25 13:27:16 »

sry I oversaw that...
I use BufferedImage and the "bug" occurs independent from the use of -Dsun.java2d.opengl=true
Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (108 views)
2017-09-30 02:57:34

theagentd (135 views)
2017-09-26 18:23:31

cybrmynd (245 views)
2017-08-02 12:28:51

cybrmynd (240 views)
2017-08-02 12:19:43

cybrmynd (238 views)
2017-08-02 12:18:09

Sralse (252 views)
2017-07-25 17:13:48

Archive (864 views)
2017-04-27 17:45:51

buddyBro (1007 views)
2017-04-05 03:38:00

CopyableCougar4 (1566 views)
2017-03-24 15:39:42

theagentd (1373 views)
2017-03-24 15:32:08
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

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!