1 / 28

Computer Science 101

Computer Science 101 . Picture Files. Computer Representation of Pictures. Common representation is as a bitmap . Two dimensional array of dots called pixels (picture element). The array consists of rows and columns of pixels.

sydnee
Download Presentation

Computer Science 101

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Science 101 Picture Files

  2. Computer Representationof Pictures • Common representation is as a bitmap. • Two dimensional array of dots called pixels (picture element). • The array consists of rows and columns of pixels. • With the RGB system, each pixel has associated a 3-byte RGB value.

  3. Picture from W&L Home Page(stored as bmp file)

  4. At 800%

  5. At 2400%

  6. How does the software know? • We know that all of the information stored in a computer file is stored as bits, broken into 8-bit bytes. • How does the software know whether this binary data is to be interpreted as text, picture, music, program instructions, etc.

  7. File extensions • As you know, files are usually stored as • Name of file • A dot (or period) • An extension that indicates the general category of the file.

  8. Some common extensions • .txt Plain text.doc Microsoft word document.docx Microsoft Word Open XML Document.pdf Portable Document Format File.msg Outlook mail message.pptPowerpoint presentation.xls Excel spreadsheet.bmp Bitmap image file.jpg JPEG image file.mp3 Mp3 audio file.wav Wave audio file

  9. Some common extensions (cont.) • .log Log file.mov Apple QuickTime movie.mpg MPEG video file.exe Executable file.html Hypertext Markup Language file.zip Zipped file.java Java source file.py Python source file

  10. Extension is not enough • Often the software needs more information than is conveyed by the extension. • A .bmp file stores the RGB values for each pixel, thus 24 bits in 3 bytes for eachpixel. • Suppose there is RGB information for 100 pixels. Is the picture a 10 by 10, 25 by 4,5 by 20 or what? Many other such questions.

  11. File headers • Many file formats specify how some needed information is to be stored in the beginning of the file. • The extension tells the type of format being used; the file header encodes additional information needed by the software accessing the file. • File has • Header information • File data

  12. BMP File Header • For more on this topic see • http://www.fastgraph.com/help/bmp_header_format.html • http://en.wikipedia.org/wiki/BMP_file_format#BMP_File_Header

  13. BMP Header (from Fastgraph)

  14. BMP Header (cont.) • Offset: • How many bytes into the file the specified information is located. Here we have 0; so this information is at the very beginning of the file. • In this table the offset is given in decimal; we’ll need to use hexadecimal. Get ready to convert. • Size: How many bytes are used for the information.

  15. BMP Header (cont.) • Signature: • Identifies the kind of file data • Often 2 byte information has the information in “right to left” order. • Here the 42 in hex is 66 in decimal. The 4D is 77 in decimal. • 66 is ASCII for B, and 77 is ASCII for M. • BM is confirming that the data is bitmap data.

  16. BMP Header (cont.) • Start of image data: • Where the RGB values are found. • Let’s remember that the offset 10 is A in hex. • Also remember that this information is 4 bytes long.

  17. BMP Header (cont.) • Width: • At offset 18 decimal or 12 hex. • 4 bytes. • Height • At offset 22 decimal or 16 hex. • 4 bytes.

  18. BMP Header Summary • Some of the header info (offsets in hex): • Signature at offset 0 – 2 bytes • File size at offset 2 – 4 bytes • Offset for start of image data at offset A – 4 bytes • Width in pixels at offset 12 - 4 bytes • Height in pixels at offset 16 – 4 bytes

  19. 96 pixels So each square is 24 by 24

  20. Colored Squares with Hex Editor • We see the 42 4D at offset 0

  21. File Size (offset 2) • We see 366C for size. • Actually bytes are right to left so 6C36. Converting this to decimal gives 27702 bytes. • We have 96 by 96 or 9216 pixels • 3 bytes per pixel for RGB; so 27648 data bytes • Plus the 54 bytes in the header giving 27702

  22. Width and Height (offset 12 and 16) • We see 60 for both the width and height. In decimal this would be 96.

  23. Bitmap Data Location (offset A) • We see 36 at location A. This means that the bitmap data begins in location 36.

  24. Bitmap Data (offset 36) • At location 36, we see values FF 00 FF. • But the upper left square has red pixels. • The BMP documents specify bottom row first. • Red and Blue give the purple color.

  25. Bitmap Data – Color Change • In the bottom row, there are 24 purple pixels, FF 00 FF. Then we see FF 00 00 24 times. • This would seem to indicate Red. • Again, the BMP specifications indicate the colors will be in BGR order.

  26. Suzie • Pup • Now

  27. We need a list to keep track of what we’ve got!

More Related