Click to See Complete Forum and Search --> : How to load binary image with 1 Bit Per Pixel ?
sharong
September 29th, 2005, 06:00 AM
Hi Everyone,
I have a TIF file 62992 x 113386 Pixels, Huffman RLE compression, 3200 x 3200 DPI resolution, binary colored (1 Bit Per Pixel), file on disk size 43.08 MB (45,169,042 Bytes).
This kind of image should consume 851.66 MB (893,028,184 Bytes) of memory when loaded, and this is exactly what I want it to consume.
Otherwise; the representation per pixel will be 1 byte (8 Bits), which means that this kind of image will require 6.652 GB (7,142,410,912 Bytes) that I absolutely can not have in any possible way.
Therefore I need to load this image as a binary image (1 Bit Per Pixel).
Can anybody tell me how can I do that please.
--------
Thanks
Sharon
cilu
September 29th, 2005, 09:01 AM
850MB of RAM to load an image is way, way too much IMO, too. This will fail on 256 MB RAM systems, for example. Are you sure that the system on which this is going to be ran has enough memory so that you can load it?
Can't you load just parts of it, as they are need for display or other kind of process? Parts that should not be bigger than 50 or 100MB?
sharong
October 2nd, 2005, 02:21 AM
I'm working on a 4GM memory PC. so there is enough memory for it.
I found that the Bitmap object can hold 1 bit per pixel, but for some
reason, that I can not understand, when loading the image it throw en exception saying "Bad argument".
And if I load the image using Image.FromFile(imageFilePath) it throw en exception saying "Out Of Memory" and it's because it consume twice the memory it should (not 8 times).
The image I'm loading is the one I mentioned in my initial post.
Other programs, like the IrfanView (http://www.irfanview.com/ (http://www.irfanview.com/)) and a project
at http://www.codeproject.com/bitmap/graphicsuite.asp (http://www.codeproject.com/bitmap/graphicsuite.asp) are loading this same
image with the exact memory.
Can you tell why the Bitmap object take twice the memory in cases like this?
---------
Thanks
Sharon
cilu
October 2nd, 2005, 04:18 PM
Other programs, like the IrfanView (http://www.irfanview.com/) and a project
at http://www.codeproject.com/bitmap/graphicsuite.asp are loading this same
image with the exact memory.
I've just tried to load an ASCII file of 320MB with IrfanView and it promted me with the error "Can't allocate enough memory for the resulting image". I'm having 1BG RAM. So you actually loaded 800MB with Iview?
Can you tell why the Bitmap object take twice the memory in cases like this?
I don't know why, but frankly, this method of allocating 800MB for a single picture doesn't look appealing to me.
sharong
October 3rd, 2005, 01:00 AM
I have some plug-ins with the IrfanView and I tried it on a 4GB RAM PC, and it consumed the exact memory (850.5MB = (62992 x 113386)/8) and succeeded to load the image with no errors.
Not every image take the twice memory amount in the Bitmap object, but for some reason it does in my case.
Actually, When loading this image to a Bitmap object, it throws en exception saying "Bad argument", and I think it because the image is a binary image with 1 bit per pixel which the Bitmap object can not handle correctly.
And if I load the image using Image.FromFile(imageFilePath) it throw en
exception saying "Out Of Memory" and it's because it consume twice the memory
it should (not 8 times the memory).
What do you think?
--------
Thanks
Sharon
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.