Graphics

Course Content Specification

The most basic method of representing graphics in a computer is by use of a bitmap image. If you zoom into a photo close enough you will see that it is made up of many little squares, or pixels (stands for picture elements).

Structure of a black and white bitmap

A bitmap graphic stores every single pixel in an image. Looking at a black and white image below. 0 is stored for a white pixel, 1 is stored for a black pixel. Each black and white pixel takes up 1 bit of storage.

Structure of a colour bitmap

A colour bitmap is very similar to that of a black white image except that instead of a single bit being used to represent the colour of the pixel a larger binary number is used.

A standard Gif image (more info here) used on the web can have a maximum of 256 colours. This means that we can represent this using a binary number of 8 bits. So the bit depth is described as 8 bits as bit depth is the size of the binary number needed to represent the colour in an image.

Bit Depth Examples

1 Bit = 2 colours

2 Bits = 4 colours

16 Bits = 65,536 colours

24 Bits = 16,777,216 colours

Most modern widescreen monitors will be displaying at 1920 x 1080 pixels (referred to as HD) with a bit depth of 24 bits.

In 24bit true colour the colour code is made up of 3 portions, with one byte indicating the number of Red, one byte indicating Green and the other Blue. These are the same three colours of 2 LED’s used in modern televisions to represent colours. Although some manufacturers are now introducing yellow pixels. These are often displayed using the Hexadecimal (Base 16 numbers) and are used extensively by HTML editors and graphic editing programs. We will cover Hex more at Advanced Higher.

Resolution

A picture with more pixels is usually a more clear and detailed picture. This picture would be said to have a higher resolution. Resolution is a measure of the amount of pixels that an image consists of. A common use of resolution is displaying the native resolution of monitors/TV or the megapixel rating of digital camera.

Compressed Image

Uncompressed Image

Dots Per Inch (DPI)

Another way to measure resolution is dpi (dots per inch) scanners will use this to measure the amount of pixels in an inch that they scan. Or printers will use this on how many pixels make up the printouts.

Vector vs Bitmap Graphics

There is one other method of representation and that is vector representation. Whereas bitmap representation stores every single pixel, vector representation stores the attributes of each object that the image is created from.

The key advantages of vector images are that:

✓ They are resolution independent. Meaning that the same quality of image will be rendered regardless of the resolution of the display or print device.

✓ They are not blurred by scaling unlike bitmap images.

✓ Individual objects can be easily selected and edited. In bitmap images editing is on a pixel by pixel basis

✓ File sizes are generally smaller as only shape attributes are stored.

However vector graphics have the following disadvantages:

They usually require a specific vector graphics package to create/edit.

They cannot represent photo realistic images.

Common Vector Attributes

SVG Code - Rectangle

<html>

<body>


<svg width="400" height="110">


<rect width="300" height="100" style="fill:rgb(0,0,255);

stroke-width:3;stroke:rgb(0,0,0)" />


</svg>

</body>

</html>

SVG Code - Circle

<html>

<body>


<svg width="100" height="100"> 

<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" /> 

</svg>


</body> 

</html>

SVG Code - Ellipse

<html> 

<body>


<svg height="140" width="500"> 

<ellipse cx="200" cy="80" rx="100" ry="50" style="fill:yellow;stroke:purple;stroke-width:2" /> 

</svg>


</body> 

</html>

SVG Code - Polygon

<html> 

<body>


<svg height="250" width="500"> 

<polygon points="150 40,220 100,185 170,115 170,80 100" style="fill:lime;stroke:purple;strokewidth:1" /> 

</svg>


</body> </html>

SVG Code - Line

<html> <body>


<svg height="210" width="500"> 

<line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" /> 

</svg>


</body> </html>

Lesson Video

Storing Graphics.mp4