Web graphics

Derek Bridge

Department of Computer Science,
University College Cork

Web graphics

Aims:

Foreground image display dimensions

The RGB colour model in (X)HTML/CSS

Wikipedia (RGB colour model)

Computer monitors

Screen size
The length of the diagonal (e.g. 12 inches)
Screen resolution
The number of pixels per inch (e.g. 106 ppi), but often we're given just total pixels (e.g. 800 × 600, 1024 × 768)
Screen colour depth
The number of bits used in the framebuffer to specify the colour of each pixel (e.g. 24 bpp)

Direct colour

Most commonly, the framebuffer directly specifies the colour of each pixel

24-bit truecolour
8 bits for red, 8 for green, 8 for blue gives 28 × 2 8 × 28 = 16,777,216 colours (millions)
32-bit truecolour
Same as 24-bit with 8 unused bits. Class exercise: Why is this popular?
8-, 12-, 15- and 16-bit direct schemes
Fewer colours but less memory: found on older hardware or handhelds

Direct colour

[Diagram showing how a framebuffer is used in a direct colour scheme.]

Indexed colour

Indexed colour

[Diagram showing how a colour lookup table is used in an indexed colour scheme.]

Images

Two main representations:

Vector graphics images
Use mathematical equations to describe the image
  • E.g. Scalable Vector Graphics (SVG)
  • Example: polygons.svg
  • Handled by Forefox, Opera, Safari, but not Internet Explorer (need a plug-in)
Bitmapped images (raster graphics images)
Specifies the colour of each pixel

Bitmapped images

Image dimensions
The width and height of the image in pixels
Class exercise: Will a 640 × 480 image be the same size in inches on all monitors?
Image file size
The number of pixels multiplied by the bits per pixel (determined by image colour depth)
Image colour depth
The number of bits used in the image to specify the colour of each pixel (e.g. 24 bpp)

Direct colour image formats

[Diagram showing how a bitmapped image uses a direct colour scheme.]

Indexed colour image formats

[Diagram showing how a bitmapped image uses a colour lookup table in an indexed colour scheme.]

Shifting and dithering

What happens if a 32- or 24-bit truecolour image is displayed on a 16-bit highcolour monitor?
The colour values are shifted up or down to the nearest available values
[Illustration of dithering.] What happens if a direct colour image (e.g. 32-/24-bit truecolour or 16-bit highcolour) is displayed on a 8-bit indexed colour monitor?
Either the colour values are shifted or dithering is used
Dithering illustration from (Dither)

Web image formats

There are many bitmapped image file formats, but browsers typically have built-in support for only the following three:

  • GIF
    • 8-bit indexed colour
  • JPEG
    • 24-bit direct colour (truecolour)
  • PNG
    • 8-bit indexed colour, or 16-bit grayscale, or 24-bit and 48-bit direct colour

Images and the web

  • How to make file sizes small without losing too much quality
  • How to make the image (esp. its colours) look the same on different platforms
  • How to make two colours match, even on the same platform