I am working on some university project and am stuck in a memory problem. I am downloading a bitmap that takes about 1.5 GB on the hard drive with the code below:
Bitmap bmp = new Bitmap(pathToFile);
The problem is that the newly created Bitmap object uses about 3.5 GB of RAM, which I cannot understand (this is really a BIG shell: E). I need to get an array of pixels, and using the Bitmap class is really useful (later I use the LockBits () method and process the byte array for each byte), but in this case it is a complete blocker. So here is my question:
Is there an easy way to extract an array of pixels without providing extra 2gb?
I use C # only to retrieve the required array, which is later processed in C ++ - maybe I can extract all the necessary data in C ++ (but the conversion problem appears here - I focus on 24bgr format)?
PS: I need to save the entire bitmap in memory, so dividing it into parts is not a solution.
PS2: just to find out some problems: I know the difference between a file extension and a file format. The downloaded file is an uncompressed bitmap of 3 bytes per pixel ~ 1.42GB in size (16k x 32k pixels), so why is the Bitmap object more than twice as large? Any problems with unpacking and conversion to another format are not performed.
Rafal chmiel
source share