A photo thats 1 mb ie 1048576 b thus takes

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: With a program like this, we could have created large.bmp out of small.bmp by resizing the latter by a factor of 4 (i.e., by multiplying both its width and it s height by 4), per the below.15 ./resize 4 small.bmp large.bmp You’re welcome to get started by copying (yet again) copy.c and naming the copy resize.c. But spend some time thinking about what it means to resize a BMP.16 Decide which of the fields in BITMAPFILEHEADER and BITMAPINFOHEADER you might need to modify. Consider whether or not you’ll need to add or subtract padding to scanlines. And be thankful that we don’t expect you to support fractional n between 0 and 1!17,18 14 Or maybe there is a message hidden in smiley.bmp too. No, there’s not. Though maybe there is. No. Maybe. And yet we used Photoshop. 16 32 You may assume that n times the size of infile will not exceed 2 – 1. 17 As we do in the Hacker Edition! 18 But we do expect you to support n = 1, the result of which should be an outfile with dimensions identical to infile’s. 15 11 < 16 This is CS50. Harvard College Fall 2010 If you’d like to play with the staff’s own implementation of resize on cloud.cs50.net, you may execute the below.19 ~cs50/pub/solutions/pset5/resize CSI.20 Alright, now let’s put all your new skills to the test. In anticipation of this problem set, I spent the past several years snapping photos of people I know, all of which were saved by my digital camera as JPEGs on a 1GB CompactFlash (CF) card.21,22 Unfortunately, I’m not very good with computers, and I somehow deleted them all!23 Thankfully, in the computer world, “deleted” tends not to mean “deleted” so much as “forgotten.” My computer insists that the CF card is now blank, but I’m pretty sure it’s lying to me. Write a program in ~/pset5/jpg/ called recover that recovers these photos. Um, what? How? Well, here’s the thing. Even though JPEGs are more complicated than BMPs, JPEGs have “signatures,” patterns of bytes that distinguish them from other file formats. In fact, most JPEGs begin with one of two sequences of bytes. Specifically, the first four bytes of most JPEGs are either 0xff 0xd8 0xff 0xe0 or 0xff 0xd8 0xff 0xe1 from first byte to fourth byte, left to right. Odds are, if you find one of these patterns of bytes on a disk known to store photos (e.g., my CF card), they demark the start of a JPEG.24 Fortunately, digital cameras tend to...
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