Open this file in xxd a hex editor by executing

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: ng red for black, a 24 ­bit BMP would store this bitmap as follows, where 0000ff signifies red and ffffff signifies white; we’ve highlighted in red all instances of 0000ff. ffffff ffffff 0000ff 0000ff 0000ff 0000ff ffffff ffffff ffffff 0000ff ffffff ffffff ffffff ffffff 0000ff ffffff 0000ff ffffff 0000ff ffffff 0000ff ffffff ffffff 0000ff 0000ff ffffff ffffff ffffff ffffff 0000ff ffffff 0000ff 0000ff ffffff ffffff ffffff ffffff 0000ff ffffff 0000ff 0000ff ffffff 0000ff ffffff 0000ff ffffff ffffff 0000ff ffffff 0000ff ffffff ffffff ffffff ffffff 0000ff ffffff ffffff ffffff 0000ff 0000ff 0000ff 0000ff ffffff ffffff Because we’ve presented these bits from left to right, top to bottom, in 8 columns, you can actually see the red smiley if you take a step back. To be clear, recall that a hexadecimal digit represents 4 bits. Accordingly, ffffff in hexadecimal actually signifies 111111111111111111111111 in binary. Okay, stop! Don’t proceed further until you’re sure you understand why 0000ff represents a red pixel in a 24 ­bit BMP file. Okay, let’s transition from theory to practice. Navigate your way to ~/pset5/bmp/. In that directory is a file called smiley.bmp. If you feel like SFTPing that file to your desktop and double ­ clicking it, you’ll see that it resembles the below, albeit much smaller (since it’s only 8 pixels by 8 pixels). Open this file in xxd, a “hex editor,” by executing the command below. xxd -c 24 -g 3 -s 54 smiley.bmp 8 Some BMPs also store the entire bitmap backwards, with an image’s top row at the end of the BMP file. But we’ve stored this problem set’s BMPs as described herein, with each bitmap’s top row first and bottom row last. 5 < 16 This is CS50. Harvard College Fall 2010 You should see the below; we’ve again highlighted in red all instances of 0000ff. 0000036: 000004e: 0000066: 000007e: 0000096: 00000ae: 00000c6: 00000de: ffffff ffffff 0000ff 0000ff 0000ff 0000ff ffffff ffffff ffffff 0000ff ffffff ffffff ffffff ffffff 0000ff ffffff 0000ff ffffff 0000ff ffffff 0000ff ffffff ffffff 0000ff 0000ff ffffff ffffff ffffff ffffff 0000ff ffffff 0000ff 0000ff ffffff ffffff ffffff ffffff 0000ff ffffff 0000ff 0000ff ffffff 0000ff ffffff 0000ff ffffff ffffff 0000ff ffffff 0000ff ffffff ffffff ffffff ffffff 0000ff ffffff ffffff ffffff 0000ff 0000ff 0000ff 0000ff ffffff ffffff ........................ ........................ ........................ ........................ ........................ ........................ ........................ ........................ In the leftmost column above are addresses within the file...
View Full Document

This note was uploaded on 03/22/2013 for the course COMP SCI CS-50 taught by Professor Malan during the Spring '10 term at Harvard.

Ask a homework question - tutors are online