Back to Challenge Set 21

Code Challenge: Storage Estimate

Difficulty  

divider

The Brief

What they asked for
We are putting photos on a device with not much room on it.
Before I buy anything I want to know how big an image actually
is, and how much I save if I drop the color quality. Give me
numbers I can read.

Write your requirements list before you write any code. Input, calculate, output, and anything you had to decide for yourself.


Notes

  • Three channels per pixel, as in Lab 10. The bits per channel is the thing that varies, so it is a parameter.
  • Eight bits to a byte. Report bytes, not bits; nobody buys storage in bits.
  • Numbers I can read is a stated requirement. 36000000 is not an answer; 36.0 MB is. Use 1,000 bytes to a kB and 1,000,000 to an MB.
  • Ignore compression entirely, and say so in your requirements list: this is the uncompressed size, the honest worst case.
  • Then try a 12000 × 9000 panorama. If its size comes out negative, you have met Activity 2.16 again. Fix it with the type 2.16 used.

Sample Output

Sample Output
64x64: 8-bit 12.3 kB 2-bit 3.1 kB
800x600: 8-bit 1.4 MB 2-bit 360.0 kB
4000x3000: 8-bit 36.0 MB 2-bit 9.0 MB

Dropping from 8 bits to 2 divides the size by exactly four, at every size. Your requirements list should predict that before you run it.


Submit

Your requirements list and your program file, named cc-storage-estimate.

Commence Challenge