• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Storing image in bits?

(oO (||||) (||||) Oo)
Loyal Member
Joined
Aug 6, 2009
Messages
2,132
Reaction score
429
SO here is deal, I have a software that runs on a pda. User has to enter couple text fields and an B&W image area is for the signature. The original software designed that each pixel from the image is a byte (0 being empty, 255 black/filled). Image is 300*180px so it comes around to around 52kb in size. This has to be sent over network to central server for whatever.

I figured why not optimize it. I know that image is fixed size 300 by 180, and it is black and white only. Why not store whole image in bits. What I mean is, instead of single pixel taking one byte (8bits) i can have single pixel take one bit (1 for filled and 0 for empty). That's about 6k total size for image.

Considering that company has about 1000 people using the software, each person sends an image 80 times a day it comes down to roughly 4200mb of data usage for images only. And since company pays for each mb of use (rate cant be disclosed) we could save couple hundred bucks for let's say a new coffe maker or toaster for the office. Also using bits will cost us around 520mb a day of data usage.

Now question to the experts and not, would you consider this as a good optimization + money saving (for new coffe maker)?

Explained more what I meat by "suing bits to store image":
8 pixel will be stored as one byte. One pixel per bit, 1 for being filled (black) and 0 being empty (white space/empty/nothing). Where is in current software each pixel takes 1 byte (8 times more space???).
 
Custom Title Activated
Loyal Member
Joined
Aug 16, 2007
Messages
1,378
Reaction score
581
you can easily implement that by using the bit wise operators like SHL SHR AND and OR to make a function that lets you store 8 bools inside a byte and retrieve them, then use an array of bytes to store the image, although you could technically just use a compression algorythm to get it down to 1 kb or less without even bothering with the bits or get a connection where you don't have to pay outrageous bandwidth prices
 
(oO (||||) (||||) Oo)
Loyal Member
Joined
Aug 6, 2009
Messages
2,132
Reaction score
429
you can easily implement that by using the bit wise operators like SHL SHR AND and OR to make a function that lets you store 8 bools inside a byte and retrieve them, then use an array of bytes to store the image, although you could technically just use a compression algorythm to get it down to 1 kb or less without even bothering with the bits or get a connection where you don't have to pay outrageous bandwidth prices

compression you say. i actually haven't thought about compression. coworker will have something to do on monday lol.
Also i spoke about this with manager and we actually might be saving even more than data usage.

Each image is stored on the main local server for a month, then sent back to archive server for 6 months and after thrown on hell knows where for another year i think.

With smaller images we will need less space for storage and more space to expand i guess.
 
Custom Title Activated
Loyal Member
Joined
Aug 16, 2007
Messages
1,378
Reaction score
581
I tested the scenario and got down to 4 KB per image by using zlib (it uses zip compress algorithm which isn't bad) and that was without using bits for each pixel so there's room for improvement
 
Back
Top