Java Reference
In-Depth Information
Pixel graphics
15
Pixel images are an essential ingredient in most graphical interfaces. They occur
as small symbols on buttons or in messages or they are the main data object, for
example in an application that displays photos. Such images are stored pixel by
pixel. We shall not create such images ourselves. Instead we focus on displaying and
manipulating existing ones.
We begin by discussing different types of pixel graphics and the Java classes for
these kinds of image. We then show how images can be displayed and manipulated.
15.1
Some graphics file types
Examples of pixel graphics are digital photos or scanned pictures. They are usually
rectangular and are composed of pixels .Apixel is a small, coloured square. These
squares are tiled to compose the picture. The possible colours vary with the type of
picture. For scanned documents the pixels are usually white or black; then one bit
is sufficient to store the information of a single pixel. Black-and-white photos are
usually stored as grey-scales. Every pixel has a value representing its 'grey-ness',
e.g. 0 white and 255 is black. For colour pictures every pixel describes a colour.
There are different ways to represent a colour. The RGB-model uses three values
which indicate the amount of red, green and blue in the colour. Often one byte is
used for each of the values, thus one pixel requires 3 bytes or 24 bits. This allows
us to define 16,777,216 different colours.
Storing pixel graphics requires a lot of memory. To store an image with
2048
1536 pixels and 24-bit colours (the format of a 3 mega-pixel digital photo)
requires 9 megabytes. In order to save disk space, images are often stored in a
compressed format. When a picture is compressed some image information might
be lost. Roughly speaking, compression combines the information on adjacent or
similar pixels. Decompressing such an image results in a coarser image than the
original one. The higher the compression rate, the more image information is lost.
With a reasonable, e.g. hardly visible, loss of image quality the aforementioned
photo can be reduced to about 1
×
5 megabytes. Photos or drawings that are not too
detailed and have a low contrast allow a higher compression rate than detailed and
.
Search WWH ::




Custom Search