Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (577)
games submitted by our members
Games in WIP (498)
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  
  quick question about volatile images  (Read 2056 times)
0 Members and 1 Guest are viewing this topic.
Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Posted 2002-12-26 16:58:07 »

If I have an array of 16 elements, each of which is a frame of animation of a ball spinning, and I have this ball spinning and bouncing around the screen in full screen mode, is it better to have it as a normal image or a volatileImage?

Kommi
Offline zparticle

Senior Member




Thick As A Brick


« Reply #1 - Posted 2002-12-26 18:05:23 »

I think a better question is "Do I want it accelerated or not?". I would think you would. The problem with puting it into a volatile image is you loose tranparency. However if you let java accelorate it for you , in an automatic image, you get the speed and the transparency.

Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Reply #2 - Posted 2002-12-27 15:05:46 »

What lines of code turn a regular image
image = Toolkit.getDefaultToolkit().getImage("image.png");
Into an "automatic" image?

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

JGO Coder


Medals: 10


falling into the abyss of reality


« Reply #3 - Posted 2002-12-27 17:53:49 »

Quote
What lines of code turn a regular image
image = Toolkit.getDefaultToolkit().getImage("image.png");
Into an "automatic" image?


You should use toolkit.createImage(), rather than toolkit.getImage().

There are several ways you can obtain automatic images.

1) Images obtained from toolkit.createImage() are eligable for hardware acceleration.

2) If you need an image that is eligable for hardware acceleration, and can also be modified, you should use :-

graphicsConfiguration.createCompatibleImage(width,height[,Transparency.BITMASK]).

Images obtained from this method will be eligable for acceleration so long as you never obtain a direct reference to the raster (getRaster()/getAlphaRaster()/etc).

Also, images will only be accelerated if they are opaque, or have a bitmask transparency(Transparency.OPAQUE and Transparency.BITMASK) - full translucency is not supported at this time.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #4 - Posted 2002-12-28 05:17:11 »

Actually, [opaque and 1-bit transparent] images loaded with Toolkit.getImage() will be accelerated if there's enough vram.

There's not much difference between Tookit.getImage and Toolkit.createImage in this sense.
Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Reply #5 - Posted 2002-12-28 16:16:00 »

Ok a few questions.
1) So how do I check if my imags are accelerated?
2)by full translucency  do you mean something like a semi transparent red color?

Im still confused concerning my original question. Could someone please post a bit of code that shows how to create an "automatic" image from an image file "image.png"

Kommi
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #6 - Posted 2002-12-29 07:42:58 »

1) currently, there's no way to find out if the image is accelerated
2) that's correct.. Check out java.awt.Transparency class for more info.
3) Use Toolkit.getImage("image.png"):
 Toolkit.getDefaultToolkit().getImage("image.png");
 (don't forget to use ImageTracker class to make sure the image is fully loaded prior to using it)

 Or, alternatively, you can use Swing's ImageIcon class to load the image:
 Image im = new javax.swing.ImageIcon("image.png").getImage();
 It'll make sure the image is loaded.

There was another thread with Chet's explanation of the conditions under which an image gets accelerated.
In short: only opaque and 1-bit transparent images are accelerated, only of there's enough vram, and only i fyou don't grab a DataBuffer (or Raster) of the image.
The image gets accelerated after a few copies of this image were made to another accelerated surface (VolatileImage or screen).
Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Reply #7 - Posted 2002-12-29 22:34:16 »

When you say one bit transparent do ou mean that a pixel has tobe either completely opaque or completely transparent for the image to be accelerated? I wanted to give my sprites semi transparent shadows, but I gues i will have to make them either completely black or granular.

Kommi
Offline leknor

Junior Member




ROCK!!!


« Reply #8 - Posted 2002-12-29 22:40:31 »

Quote
When you say one bit transparent do you mean that a pixel has tobe either completely opaque or completely transparent for the image to be accelerated?

Yes, that is what he means. As for the shadows one hack would be a checkerboard pattern of black and transparent pixels.
Offline Abuse

JGO Coder


Medals: 10


falling into the abyss of reality


« Reply #9 - Posted 2002-12-30 02:07:10 »

Quote
Actually, [opaque and 1-bit transparent] images loaded with Toolkit.getImage() will be accelerated if there's enough vram.

There's not much difference between Tookit.getImage and Toolkit.createImage in this sense.


The reason I was recommending the use of createImage() over getImage() was solely based on the comments in the java doc with regard to caching <tapping of ctrl+c/ctrl+v>

Quote

public abstract Image getImage(String filename)

Returns an image which gets pixel data from the specified file, whose format can be either GIF, JPEG or PNG. The underlying toolkit attempts to resolve multiple requests with the same filename to the same returned Image. Since the mechanism required to facilitate this sharing of Image objects may continue to hold onto images that are no longer of use for an indefinite period of time, developers are encouraged to implement their own caching of images by using the createImage variant wherever available.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
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.

xsi3rr4x (22 views)
2014-04-15 18:08:23

BurntPizza (17 views)
2014-04-15 03:46:01

UprightPath (31 views)
2014-04-14 17:39:50

UprightPath (15 views)
2014-04-14 17:35:47

Porlus (31 views)
2014-04-14 15:48:38

tom_mai78101 (57 views)
2014-04-10 04:04:31

BurntPizza (115 views)
2014-04-08 23:06:04

tom_mai78101 (214 views)
2014-04-05 13:34:39

trollwarrior1 (182 views)
2014-04-04 12:06:45

CJLetsGame (189 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
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!