Problem 46913. How many bytes an image requires from RAM?
Several algorithms store compressed images at our computers; types such as FIG, JPG, or PNG help software to identify them. On the other hand, whenever we visualize an image on a display screen, it must be decompressed to its total size: displaying a compressed image is utterly incomprehensible to humans. Your task is to compute this total size.
An image total size in bits is calculated with the following formula: , in which w is its width, h is its height, δ is its pixel depth, the number of bits used to store color intensity. Usually, image dimensions are easily obtained from any software, but its pixel depth is not always available. Nevertheless, it is easy to guess the latter since:
Compute how many bytes an image requires from RAM, given its w, h, and a string informing the type of the image: BW, L, RGB, or RGBA. Moreover, make the results more human-readable by showing them with units: bytes (), KB (), MB (), GB () rounded to 2 decimal places. There must be at least a non-zero integer value to display it in some units, you should always use the greatest unit possible, and data cannot be stored in less than 1 byte (8 bits).
How many bytes a video requires from RAM?
Solution CommentsShow comments
Problem Recent Solvers13