note12 - CSCI 120 Introduction to Computation On bitmaps...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSCI 120 Introduction to Computation On bitmaps, colors, graphs, and more (draft) Saad Mneimneh Visiting Professor Hunter College of CUNY 1 A bitmap Consider the following 4x3 pixel image, which can be created using the Paint software in Microsoft Windows. Figure 1: A 4x3 pixel image When saved as a bitmap, the image is encoded in binary where each individ- ual pixel is represented by three bytes (24 bits). This representation depends on the color of the pixel, and uses the RGB color scheme. In RGB, each color is obtained as a mixture of three colors with different intensities: Red, Green, and Blue. Therefore, each of the three bytes defines the intensity of the corre- sponding color, a value that will range from 0 to 255 (because 256 patterns are possible with 8 bits). The figure below shows how three color light beams mix on a black surface. Figure 2: RGB color Because three light beams with different intensities can produce a range of colors on a black surface (no color), RGB is called additive. In contrast, printers use a subtractive color scheme in which the ink drops subtract colors from white (the paper). An example of a subtractive color scheme is CYMK (Cyan, Yellow, Magenta, and Black). For instance, Cyan subtracts the red from white so we see cyan (see RGB above). Black is used for economical reasons (colored ink is more expensive), and because it produces better quality black then the one obtained by combining Cyan, Yellow, and Magenta. Viewing the binary file produced for the above 4x3 image requires a special file reader because most of the software applications that read files assume that files contain text and, therefore, convert bytes to characters using ASCII. A good file reader for viewing binary is fb , which can be downloaded from the course website. If we save the image as patch.bmp, then typing fb -b patch.bmp at the command prompt will display the following: 1 2 3 4 5 6 7 00: 01000010 01001101 01011010 00000000 00000000 00000000 00000000 00000000 08: 00000000 00000000 00110110 00000000 00000000 00000000 00101000 00000000 16: 00000000 00000000 00000100 00000000 00000000 00000000 00000011 00000000 24: 00000000 00000000 00000001 00000000 00011000 00000000 00000000 00000000 32: 00000000 00000000 00100100 00000000 00000000 00000000 00000000 00000000 40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 48: 00000000 00000000 00000000 00000000 00000000 00000000 11111111 11111111 56: 11111111 11111111 11111111 11111111 11111111 11111111 11111111 00000000 64: 00000000 11111111 00000000 00000000 00000000 00000000 00000000 00000000 72: 00000000 00000000 00000000 11111111 11111111 11111111 11111111 00000000 80: 00000000 00000000 11111111 00000000 00000000 00000000 00000000 11111111 88: 11111111 11111111 We can also choose to display the bytes in decimal by typing fb -d patch.bmp instead: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 00: 066 077 090 000 000 000 000 000 000 000 054 000 000 000 040 000 16: 000 000 004 000 000 000 003 000 000 000 001 000 024 000 000 000...
View Full Document

This note was uploaded on 03/27/2010 for the course CSCI 120 taught by Professor Saadmneimneh during the Spring '09 term at CUNY Hunter.

Page1 / 9

note12 - CSCI 120 Introduction to Computation On bitmaps...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online