How many bytes is a byte a dword a long and a word

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: reen rgbtRed rgbtBlue rgbtGreen rgbtRed BITMAPINFOHEADER BYTE BYTE BYTE rgbtBlue rgbtGreen rgbtRed RGBTRIPLE BITMAPFILEHEADER RGBTRIPLE RGBTRIPLE ... 243 244 245 As this figure suggests, order does matter when it comes to structs’ members. Byte 57 is 10 rgbtBlue (and not, say, rgbtRed), because rgbtBlue is defined first in RGBTRIPLE. Now go ahead and pull up the URLs to which BITMAPFILEHEADER and BITMAPINFOHEADER are attributed, per the comments in bmp.h. You’re about to start using MSDN (Microsoft Developer Network)! Rather than hold your hand further on a stroll through copy.c, we’re instead going to ask you some questions and let you teach yourself how the code therein works. As always, man is your friend, and so, now, is MSDN. If not sure on first glance how to answer some question, do some quick research and figure it out! You might want to turn to the below resource as well. 10 Our use, incidentally, of the __attribute__ called __packed__ ensures that gcc does not try to “word ­align” members (whereby the address of each member’s first byte is a multiple of 4), lest we end up with “gaps” in our structs that don’t actually exist on disk. 9 < 16 This is CS50. Harvard College Fall 2010 Allow us to suggest that you also run copy within gdb while answering these questions. Set a breakpoint at main and walk through the program. Recall that you can tell gdb to start running the program with a command like the below at gdb’s prompt. run smiley.bmp copy.bmp If you tell gdb to print the values of bf and bi (once read in from disk), you’ll see output like the below, which we daresay you’ll find quite useful. {bfType = 19778, bfSize = 246, bfReserved1 = 0, bfReserved2 = 0, bfOffBits = 54} {biSize = 40, biWidth = 8, biHeight = -8, biPlanes = 1, biBitCount = 24, biCompression = 0, biSizeImage = 192, biXPelsPerMeter = 2834, biYPelsPerMeter = 2834, biClrUsed = 0, biClrImportant = 0} In ~/pset5/questions.txt, answer each of the following questions in a sentence or more. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. What’s stdint.h? What’s the point of using uint8_t, uint32_t, int32_t, and uint16_t in a program? How many bytes is a BYTE, a DWORD, a LONG, and a WORD, respectively?11 What (in ASCII, decimal, or hexadecimal) must the first two bytes of any BMP file be?12 What’s the difference between bfSize and biSize? What does it mean if biHeight is negative? What field in BITMAP...
View Full Document

Ask a homework question - tutors are online