Raster and Vector Images

The graphics world divides images into two types: raster and vector.

A raster image (also called bitmap) is a collection of one or more pixels. Each pixel of the image can be controlled individually, which means that each pixel of the image can have a different color or shade. In a raster image that contains a line and a rectangle, the line and rectangle are each a sequence of pixels. Raster images require higher resolutions and anti-aliasing for a smooth appearance and are best suited for photographs and images with shading.

A vector image is a collection of one or more vectors. Mathematically, a vector is a combination of a magnitude and a direction, which can be used to represent the relationships between points, lines, curves, and filled areas. In vector images, a vector is the entity to be controlled. Each vector can have a separate color or shade. So a vector image with a line and a rectangle is a set of vectors in which each vector has different properties, such as color or shade. Vector graphics are mathematically described and appear smooth at any size or resolution, and they are often used by mechanical and architectural engineers.

Vector images can be transformed from one state to another without any loss of data. Transforming raster images, however, may cause data loss or reduce the quality of images. For example, in the zoomed raster image shown in Figure 7.1, the outer boundary of the image is blurry.

Figure 7.1. A zoomed raster image

graphics/07fig01.jpg

In the zoomed vector image of Figure 7.2, however, the outer boundary of the image is sharper.

Figure 7.2. A zoomed vector image

graphics/07fig02.jpg

7.1.1 Raster Image Formats

A bitmap is usually stored in an array of bits that specify the color of each pixel in a rectangular array of pixels. The bitmap's height and width are measured in pixels. The number of bits per pixel specifies the number of colors that can be assigned to that pixel, according to the equation

Nc=2Bp

where

Nc = the number of colors that each pixel can display

Bp = the number of bits per pixel

For example, if Bp = 8, then Nc = 28 = 256 colors. If Bp = 24, then Nc = 224 = 16,777,216 colors. Table 7.1 shows the number of bits and number of possible colors that can be assigned to a pixel.

Bitmaps with 1 bit per pixel are called monochrome images. Monochrome images generally store two colors: black and white.

7.1.2 Graphics File Formats

There are many bitmap image formats, including the following:

  • BMP
  • GIF
  • JPEG
  • EXIF
  • PNG
  • TIFF

7.1.2.1 BMP

BMP is a standard Windows format to store device-independent and application-independent bitmap images. The number of bits per pixel (1, 4, 8, 16, 24, 32, or 64) for a given BMP file is specified in a file header. BMP files with 24 bits per pixel are common.

Table 7.1. Number of bits and possible number of colors per pixel

Bits

Colors

1

21 = 2

2

22 = 4

4

24 = 16

8

28 = 256

16

216 = 65,536

24

224 = 16,777,216

7.1.2.2 GIF

Graphics Interchange Format (GIF) is a common format for images that appear on Web pages. GIF uses Lempel-Ziv-Welch (LZW) compression to minimize file size. No information is lost in the compression process; a decompressed image is exactly the same as the original. GIF files can use a maximum of 8 bits per pixel, so they are limited to 256 colors.

7.1.2.3 JPEG

Joint Photographic Experts Group (JPEG) is another popular format used on Web pages. JPEG can store 24 bits per pixel, so it is capable of displaying more than 16 million colors. Some information is lost during JPEG conversion, but it usually doesn't affect the perceived quality of the image. JPEG is not a file format; it is a compression scheme. JPEG File Interchange Format (JFIF) is a file format commonly used for storing and transferring images that have been compressed according to the JPEG scheme.

7.1.2.4 EXIF

Exchangeable Image File (EXIF) is a file format used by digital cameras. It was originally developed by the Japan Electronic Industry Development Association. The EXIF file contains an image compressed according to the JPEG specification.

7.1.2.5 PNG

Portable Network Graphics (PNG) format provides the advantages of the GIF format but supports greater color depth. PNG files can store colors with 8, 24, 32, or 48 bits per pixel, and grayscales with 1, 2, 4, 8, or 16 bits per pixel. PNG also supports alpha channel, so it's a suitable format for storing images that support a high number of colors with transparency.

7.1.2.6 TIFF

Tag Image File Format (TIFF or TIF) can store images with arbitrary color depth, using a variety of compression algorithms. The TIFF format can be extended as needed by the approval and addition of new tags. This format is used by engineers when they need to add information in the image itself.

Almost all image file formats can also store metadata related to the image, such as scanner manufacturer, host computer, type of compression, orientation, samples per pixel, and so on.

GDI+: The Next-Generation Graphics Interface

Your First GDI+ Application

The Graphics Class

Working with Brushes and Pens

Colors, Fonts, and Text

Rectangles and Regions

Working with Images

Advanced Imaging

Advanced 2D Graphics

Transformation

Printing

Developing GDI+ Web Applications

GDI+ Best Practices and Performance Techniques

GDI Interoperability

Miscellaneous GDI+ Examples

Appendix A. Exception Handling in .NET



GDI+ Programming with C#
GDI+ Programming with C#
ISBN: 073561265X
EAN: N/A
Year: 2003
Pages: 145

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net