Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  Using video ram to store images?  (Read 4368 times)
0 Members and 1 Guest are viewing this topic.
Offline Harley Rana

Junior Devvie

Java games rock!

« Posted 2002-11-17 00:15:43 »

Hi i know video ram is the best place to store images, bliting from video ram into the current buffer should be heaps quicker.

The question is how do you load the image into the video ram?

Is it being done automaticlly?

What is the best design to load and blit images?

Thanks heaps for any help!
Offline Orangy Tang

JGO Kernel

Medals: 57
Projects: 11

Monkey for a head

« Reply #1 - Posted 2002-11-17 08:00:33 »

First off you'll have to be using 1.4, otherwise you won't be able to take advantage. Secondly have a look for VolatileImage, which is stored only in vRam and which you need to do management of image loss manually. However there are a couple of snafus that may trip you up with volative images, namely i dont think you can do any sort of transparency  Shocked

There's also 'AutomaticImages' which are regular BufferedImages which the VM will attempt to cache in vRam, and handle management itself. With the correct massaging you can also get these to have 1-bit transparency and still be hardware accelerated.

A code snippit from my (now on permanent hold,  Embarrassed ) Phoenix project:
      /** Loads image, creates automatic image/buffered image and copies it into it.
        * Currently only tested with gifs, so undefined if any other file path is passed to it.

      public BufferedImage loadImage(String filename, boolean solid)
            // Load image from file.
            Image tempImage = new ImageIcon(filename).getImage();
            BufferedImage sprite = null;
            // Get dimensions of image
            int spriteW = tempImage.getWidth(null);
            int spriteH = tempImage.getHeight(null);
            if (spriteW != -1)
                  // If a solid tile, load as such. Otherwise use bitmask transparency
                  if (solid)
                              sprite = graphicsConfig.createCompatibleImage(spriteW, spriteH, Transparency.OPAQUE);
                              sprite = graphicsConfig.createCompatibleImage(spriteW, spriteH, Transparency.BITMASK);
                  // Copy from Image to BufferedImage
                  Graphics2D g = (Graphics2D)sprite.getGraphics();
                  g.drawImage(tempImage, null, null);
                  System.out.println("Error loading images: " + filename + " not found");
            return sprite;

Jeff et al, if you're reading this - how long until we see a full site with the articles section up again?

[ - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Harley Rana

Junior Devvie

Java games rock!

« Reply #2 - Posted 2002-11-19 05:46:27 »

So the key method is createCompatibleImage, which is used to create AutomaticImages.

Is there much difference between normal awt.Images, loaded from ImageIO, to automatic images?
Assuming the sprites are tranparent.

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

Senior Devvie

If only I knew what I'm talking about!

« Reply #3 - Posted 2002-11-20 01:34:36 »

Currently none of the images loaded with ImageIO are accelerated, as opposed to those loaded with Toolkit.getImage() , for example.
Offline trembovetski

Senior Devvie

If only I knew what I'm talking about!

« Reply #4 - Posted 2002-11-20 01:41:53 »

Also, note that in order to take advantage of those images being accelerated, you need to copy them to the accelerated back-buffer. You should use VolatileImage for the back-buffer.
Check out the articles on
for more info.
Offline swpalmer

JGO Coder

Exp: 12 years

Where's the Kaboom?

« Reply #5 - Posted 2002-11-20 03:18:25 »

I hope that the Toolkit.getImage methods will soon be replaced under the hood with the ImageIO stuff anyway.. it will get rid of some redundant code...   If so, I assume that ImageIo based images will be accelerated.. maybe for 1.5?

Offline trembovetski

Senior Devvie

If only I knew what I'm talking about!

« Reply #6 - Posted 2002-11-21 03:37:21 »

Yep, that's the plan.
Pages: [1]
  ignore  |  Print  

EgonOlsen (77 views)
2018-06-10 19:43:48

EgonOlsen (57 views)
2018-06-10 19:43:44

EgonOlsen (77 views)
2018-06-10 19:43:20

DesertCoockie (259 views)
2018-05-13 18:23:11

nelsongames (157 views)
2018-04-24 18:15:36

nelsongames (156 views)
2018-04-24 18:14:32

ivj94 (897 views)
2018-03-24 14:47:39

ivj94 (161 views)
2018-03-24 14:46:31

ivj94 (810 views)
2018-03-24 14:43:53

Solater (174 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

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