Java Graphics  «Prev  Next»

Lesson 5Understanding images
ObjectiveLearn what images Java supports and how it supports them

Understanding Images in Java

Which images are supported

Understanding Images
Java supports images through the Image class, which is defined in the java.awt package. The Image class encapsulates the rectangular pixel data of an image and provides methods for drawing and accessing image information. For example, the getWidth() and getHeight() methods obtain the width and height of an image, respectively.

Image types

There are many different formats for representing an image's pixel data. Java supports two major image formats, JPEG and GIF, each of which are geared toward representing a certain type of image.

JPEG Image
JPEG
JPEG (Joint Photographic Experts Group): provides a highly efficient means of storing photographic images; image files typically have a .jpg file extension

GIF image
GIF

GIF (Graphics Interchange Format): useful for storing images other than photographs such as illustrations and diagrams; imagefiles typically have a .gif file extension