Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Games Center / Showcase / Re: Sinuosity - A Simple Maze-Solving Dungeon Crawler on: 2008-06-13 19:22:04
Yeah cool game,

But definitely need a reset button.
2  Game Development / Performance Tuning / Re: Creating small BufferedImages from large BufferedImage on: 2008-06-13 19:08:05
Thanks for the reply Fletcher.

I was experimenting with it more and trying Volatile Images and I discovered the problem.

When you load in a png with ImageIO it can sometimes be read in as a translucent image. If I copied that to a BITMASK buffered image it was then able to be accelerated.

I am still looking for a way to force initially loading it as a BITMASK transparency, but for now this works.

While the addition optimization might help, I am going to hold off since this is only done once during loading, not in a game loop.

Thanks
3  Game Development / Performance Tuning / Creating small BufferedImages from large BufferedImage on: 2008-06-13 00:38:36
Hello Java Gaming Community.

I heard from Sun that this is the place to post about Java2D performance questions.

I am working on the Java Instructional Gaming Engine. We are trying to speed up the performance on our spritesheet loading code. Basically we have an XML file and Image pair that are loaded at the beginning of games. Each animation has to copy out all of the frames out of the main image.

From my testing I have found that the larger the main image is, the longer it takes to load. While the obvious solution might be just to not use big images, it is bound to happen when students are using the engine.

I have extracted essentially what we are doing into the code below. We are doing a little more than this with setting frame properties etc. but this is basically it.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;

public class LoadTest {
   
   Frame frame;
   URL sheetURL;
   BufferedImage sheetImage;
   
   public static void main(String[] args) {
      //System.setProperty("sun.java2d.opengl", "True");
           
      new LoadTest();
   }
   
   public LoadTest()
   {
      long st = System.nanoTime();
      frame = new Frame();
     
      sheetURL = ClassLoader.getSystemResource("bugs.png");
     
      try {
         sheetImage = ImageIO.read(new BufferedInputStream(sheetURL
               .openStream()));

      } catch (IOException e) {
         sheetImage = null;
         System.err.println("IO Exception while loading image '"
               + sheetURL.toString() + "'");
         return;
      }
     
      for(int i=0; i<10; ++i)
         load(i);      
     
      long t = ((System.nanoTime()-st)/(1000000));
      System.out.println("Total Load Test took " + t + " ms");
   }
   
   public boolean load(int i)
   {      
      int width = 20;
      int height = 20;
      int top = i * height;
      int left = 0;
      int rows = 1;
      int columns = 10;
     
      long st = System.nanoTime();
           
      BufferedImage[] bframes = new BufferedImage[rows * columns];
      for (int y = 0; y < rows; ++y) {
         for (int x = 0; x < columns; ++x) {
            bframes[y * (columns) + x] = createImageResource(
                  sheetImage, Transparency.BITMASK, width,
                  height, left + width * x, top + height * y);
         }
      }      
      long t = ((System.nanoTime()-st)/(1000000));
      System.out.println("Created Image List with " + (rows*columns) + " elements in " +
               t + " ms for resource ");
     
      return false;
   }

   protected BufferedImage createImageResource(final BufferedImage originalImg,
         final int transparency, final int w, final int h,
         final int xoffset, final int yoffset) {

      BufferedImage r = drawImage(originalImg, transparency, w, h, -xoffset,
            -yoffset);
      return r;
   }
   
   protected BufferedImage drawImage(final Image i, final int transparency, final int w, final int h,
         final int xoffset, final int yoffset)
   {
      GraphicsConfiguration gc = frame.getGraphicsConfiguration();
      BufferedImage image = gc.createCompatibleImage(w, h, transparency);
      image.getGraphics().drawImage(i, xoffset, yoffset, null);
     
      return image;
   }
}


I have attached the images to this post. Here are my run times for each.
bugs.png - Total Load Test took 1206 ms
bugs_large.png Total Load Test took 17638 ms

Do you guys have any suggestions on how we could speed this up?

Thanks,
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

E.R. Fleming (16 views)
2014-07-29 03:07:13

E.R. Fleming (5 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

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

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

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

MustardPeter (44 views)
2014-07-16 23:30:00
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!