Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (591)
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 2681 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!
Harley.
Offline Orangy Tang

JGO Kernel


Medals: 56
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:
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  
      /** 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);
                  else
                              sprite = graphicsConfig.createCompatibleImage(spriteW, spriteH, Transparency.BITMASK);
                 
                 
                  // Copy from Image to BufferedImage
                  Graphics2D g = (Graphics2D)sprite.getGraphics();
                 
                  g.drawImage(tempImage, null, null);
                  g.dispose();
            }
            else
            {
                  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?

[ TriangularPixels.com - 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.

Thanks.
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
http://java.sun.com/products/java-media/2D/
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  
 
 
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.

trollwarrior1 (34 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (66 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04

CopyableCougar4 (82 views)
2014-11-01 23:36:41
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!