Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
Omer Boyaci
(C) 2010
Pearson
Education,
Inc. All rights
reserved.
Omer Boyaci
private BufferedImage im;
im = ImageIO.read( getClass().getResource("ball.gif"));
Image Loading
(C) 2010 Pearson Education, Inc. All rights
reserved.
public BufferedImage loadImage(String fnm){
/* Load the image from , returning it as a BufferedImage
which is compatible with the graphics device being used. Uses ImageIO. */
try {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment( );
GraphicsConfiguration gc =
ge.getDefaultScreenDevice( ).getDefaultConfiguration( );
BufferedImage im = ImageIO.read(getClass( ).getResource(fnm));
int transparency = im.getColorModel( ).getTransparency( );
BufferedImage copy = gc.createCompatibleImage(
im.getWidth( ),im.getHeight( ),transparency );
// create a graphics context
Graphics2D g2d = copy.createGraphics();
// copy image
g2d.drawImage(im,0,0,null);
g2d.dispose( );
return copy;
}
catch(IOException e) {
System.out.println("Load Image error for " + fnm + ":\n" + e);
return null;
}
} // end of loadImage( )
(C) 2010 Pearson Education, Inc. All rights
reserved.
Image Names
(C) 2010 Pearson Education, Inc. All rights
reserved.
You can load
individual images
image strips
multiple image files that represent an
animation sequence.
Animation
(C) 2010 Pearson Education, Inc. All rights
reserved.
Animation Types
(C) 2010 Pearson Education, Inc. All rights
reserved.
// imsInfo.txt images
o atomic.gif
o balls.jpg
o bee.gif
o cheese.gif
o eyeChart.gif
o house.gif
o pumpkin.png
o scooter.gif
o ufo.gif
o owl.png
n numbers*.gif 6
n figure*.gif 9
g fighter left.gif right.gif still.gif up.gif
s cars.gif 8
s cats.gif 6
s kaboom.gif 6
o basn6a08.png
o basn6a16.png
(C) 2010 Pearson Education, Inc. All rights
reserved.
o
n
s
g [ ]*
Strip file
(C) 2010 Pearson Education, Inc. All rights
reserved.
Swing Timer
(C) 2010 Pearson Education, Inc. All rights
reserved.
ImagePlayer
(C) 2010 Pearson Education, Inc. All rights
reserved.
Java Games
Runescape
http://www.runescape.com/
Stellar Dawn
http://www.stellardawn.com/
Wakfu
http://www.wakfu.com/
Tribal Trouble 2
http://tribaltrouble2.com/
Pirate Galaxy
http://us.pirategalaxy.net
Resistance Force
http://www.resistanceforce.com/
Urban Galaxy
http://www.urbangalaxyonline.com/
Poisenville http://www.poisonville.com/
Chrome http://www.techland.pl/?id=produkty&pro
dukt=179
Wurm http://wurmonline.com/
Cell Invaders - TowerDefense http://www.krautsoft.vs241092.vserver.d
e/virchow/index.html
Wezzle
http://couchware.ca/www/wezzle/
CEPHEI - HOSTILE PLANET
http://jalex.se/Cephei/bin/game.html