Jump to content

Bitmap storage question


al3xand3r
 Share

Recommended Posts

I am working on some very small images for a custom WPS (while playing screen) for Rockbox on my iriver.

Anyway, the images have to be in bitmap format. Out of curiosity, I right-clicked on the folders to see "Properties" and saw the following:

Size: 109KB

Size on Disk: 780KB

Contains: 195 files, 15 folders

I right-clicked on another folder containing JPEG images, and the difference was very small, a fraction of the total, whereas with the bitmap-only folders the difference is 7 times or more. Why is there such a huge discrepancy between size and size on disk with bitmap files? Just something I'd like to understand.

Link to comment
Share on other sites

Harddrives are set up into sectors, and if a file takes up any part of a sector, that entire sector "belongs" to that file. Generally that size is 4k (4,096 bytes) but it can be changed when you format the drive. (Check the size on disk of a shortcut to see the size on your drive.)

So, any file less than 4k is going to take up 4k of disk space no matter how small it is, and if you have a folder full of 100 byte files, each of them is going to take up a really high amount of space, proportionally.

Link to comment
Share on other sites

Vaguely speaking, "Size" refers to how big the files are, while "Size on disk" is how much space they actually take up on the disk. Each little file segment has to have it's own little cluster or whatever it's called; if there's a lot of file segments which only take up small portions of clusters then there's going to be a big difference between "Size" and "Size on disk". This also means that depending on cluster size you'd be able to fill up space on a hard drive while only actually using something like 1/8 of the HDD space. Since bitmaps aren't compressed and map every single pixel, they're more prone to this for whatever reason.

I haven't actually done anything relating to computer science and whatnot in a while, so if this explanation isn't good enough then someone should come around soon enough to give a more in-depth description of what's going on.

Edit: Jacked by Xerol.

Edit2: Actually, I think that last statement in the first paragraph may be misleading - It's just that bitmap files of the same resolution would all be the same file size, and if all your bitmaps are like 5k each and you have 4k clusters then each bitmap will take up two 4k clusters.

Link to comment
Share on other sites

Edit2: Actually, I think that last statement in the first paragraph may be misleading - It's just that bitmap files of the same resolution would all be the same file size, and if all your bitmaps are like 5k each and you have 4k clusters then each bitmap will take up two 4k clusters.

Except it's a really high ratio of useful/used space, and the only way that can happen is if the files are significantly smaller than the sector size.

This also means that depending on cluster size you'd be able to fill up space on a hard drive while only actually using something like 1/8 of the HDD space. Since bitmaps aren't compressed and map every single pixel, they're more prone to this for whatever reason.

It doesn't really have anything to do with compression, except for certain specific cases (say a 32-bit bitmap that's 32x32, there's 4,096 bytes of data and then a 23-some byte header on top of that, meaning you're wasting over 4,000 bytes per file, so using PNG would save you at least 4k per file in this scenario (I think PNG is guaranteed to come out smaller than BMP at maximum compression)). A 4k cluster size is a good compromise, anything bigger and you'd see a LOT more wasted space (before my HD crash, I had about 150,000 files that were less than 1k in size; an 8k cluster size would've meant 600 megs of wasted space) but smaller cluster sizes slow down access times and on older machines limit the size of a single partition (although I think on current machines you can go up to something like a million TB with a 4k size) and for 99.999% of users you don't need to use anything else.

Link to comment
Share on other sites

It doesn't really have anything to do with compression, except for certain specific cases (say a 32-bit bitmap that's 32x32, there's 4,096 bytes of data and then a 23-some byte header on top of that, meaning you're wasting over 4,000 bytes per file, so using PNG would save you at least 4k per file in this scenario (I think PNG is guaranteed to come out smaller than BMP at maximum compression)).

Almost any kind of compression will result in a smaller file, bitmaps are completely uncompressed.

Link to comment
Share on other sites

If the file system is set up to use very large clusters, then it doesn't inherently matter what the files' actual sizes are. The easiest way to see this in action is to create a blank text file on your own computer, and then check its size in file properties. It'll say size 0 bytes, size on disk 4096 bytes (or whatever your cluster size is set to).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...