您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)

 

Content Index

Content Page # 20

images

An image is a file that represents an image using some standard grapichical image file format (such as GIF and JPEG). Java's Graphics class can draw bitmapped images in such file formats.

images (from any source) are objects of class image. The retrieval of an image may take some time (e.g. from a distance web site), so it is carried out in the background.

The technicalities of retrieving and displaying an image are quite complex (involving about six different classes) but this is mostly hidden from the programmer.

The method 'drawimage()' in the Graphics class draws an object of class image on the screen.

There are a variety of techniques for getting an image object that represents a specific image file. In a Java applet, the simplest technique is probably to use the getimage() method in the Applet class. So displaying an image from a GIF file could be as simple as this (in an applet):

image image = getimage("test.gif");

g.drawimage(image, 0, 0, this);

Note that getimage() can retrieve images from a remote computer using a URL.

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg