Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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  
  Slick -> First copy() that rotate and than subimage  (Read 1605 times)
0 Members and 1 Guest are viewing this topic.
Offline biro

Junior Member


Medals: 1
Projects: 1



« Posted 2011-04-29 19:28:09 »

Hello,
like the topictheme already says I'm trying to use Slick (it's my first time) and my programm works surprising well, but now I met my first error^^
To the Problem:
I have a few "master"pictures, that I create once and don't reload if I've used them. Now I want to rotate this picture, but because I don't want to work with my master picture I make a copy of it, with the simple command copy() so far so easy. Not I use the rotate command on it (I rotate it 90, 180, 270 and 0 degrees), and than I need a little part of this rotated picture on my display, to get this little part I use the subImage command from the Image class of Slick.

My Problem is, that after I do all that and my programm shows me the result I see, that I have a subimage of the picture, which isn't rotated... I think, that the problem is the shadow copy that the copy command created... But I'm not sure how to make a FAST hard copy... Maybe you can help me.

Here the code:

1  
2  
3  
4  
5  
         
                        Image draw = img.copy();
         draw.rotate(grad);
         Image newdraw = draw.getSubImage(actx, acty, this.tilewidth-actx, this.tileheigth-acty);
         newdraw.draw(0, 0);


Thanks alot for your help, if this isn't enough code just ask me.

biro
Offline biro

Junior Member


Medals: 1
Projects: 1



« Reply #1 - Posted 2011-04-30 11:07:44 »

Hello,
sorry if I should do a kind of double post now, but I believe that it's stylistic better if I write this in a new post.

Today I continued to experiment on my mĀ“litte Programm and the result is very satisfying, or at least half satisfying!
I got my programm so far that it draw the picture now correct, meaning a subimage of the rotated original. Looks like the only thing that needed to be done was a flush() on the graphics of the copy. The only thing I don't like is that everytime my programm shows me now the picture it also says:  

Sat Apr 30 10:58:22 CEST 2011 INFO:Offscreen Buffers FBO=true PBUFFER=true PBUFFERRT=true
Sat Apr 30 10:58:22 CEST 2011 DEBUG:Creating FBO 50x50

Can someone translate that for me in an english that I can understand please?^^

Here the used code:
1  
2  
3  
4  
5  
      Image draw = img.copy();
         draw.rotate(grad);
         Image aimg = this.getCopy(draw);
         Image newdraw = draw.getSubImage(actx, acty, this.tilewidth-actx, this.tileheigth-acty);
         newdraw.draw(0, 0);


And here the getCopy() Method, that only does flush at the moment...

1  
2  
3  
4  
5  
6  
7  
  private Image getCopy(Image img) throws SlickException {
      Image aimg = new Image(img.getWidth(), img.getHeight());
      Graphics g = img.getGraphics();
      //g.copyArea(aimg, 0, 0);
     g.flush();
      return aimg;
  }


What I now don't understand is why the flush is needed, for that the subimage gets taken form the rotated picture and not from the not rotated one, maybe someone can explain that to me. And maybe someone has another Idea for how to write it shorter.

Greetings
biro

Edit:
It looks like that my rotation method kills my fps... while I have an undrosseled fps from between 3000 and 5000 I have only and fps of about 20 when my screens shows and rotated picture... Hope someone can help me and has an more efficient way to get a subimage from an rotated image...

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.

ctomni231 (36 views)
2014-07-18 06:55:21

Zero Volt (34 views)
2014-07-17 23:47:54

danieldean (27 views)
2014-07-17 23:41:23

MustardPeter (30 views)
2014-07-16 23:30:00

Cero (44 views)
2014-07-16 00:42:17

Riven (46 views)
2014-07-14 18:02:53

OpenGLShaders (35 views)
2014-07-14 16:23:47

Riven (35 views)
2014-07-14 11:51:35

quew8 (31 views)
2014-07-13 13:57:52

SHC (67 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!