Loading a lot really small BMP files. -> Memory problems

Posted By: Puppeteer

Loading a lot really small BMP files. -> Memory problems - 04/11/12 13:15

Hi!

In my current project I use BMPs to read vectors from them in context of the bitmaps. I currently use 5.5k bitmaps and it is going to be like ~20k when the project is done.
Those 5.5k bitmaps swallow ~400mb of my nexus but only 20mb on my harddrive. The data encoded in the bitmaps is already 4x compressed so reducing this any further will not help, i guess and i think this is not the issue.

The bitmaps have variable sizes and i need the data pretty much all the time. They will never be shown, their only purpose is just to get the data from them.

Is there a way to reduce the memory usage, like encoding the data in a struct? Or reading the files not as a bitmap but as pure data? What would be a good way to do this?

Oh, and if anyone can explain to me why they swallow up so much space i would be happy to know the reason =)

Thanks in advance.
Posted By: sivan

Re: Loading a lot really small BMP files. -> Memory problems - 04/11/12 13:39

you could store the data in a file, by file_var_write/read, and store your vectores in the memory at runtime as an array of VECTOR*, allocating memory by sys_malloc, or if dynamic array size is needed by malloc/realloc. of course an array of a struct also can be used if not only vectors are needed to be stored.
Posted By: EvilSOB

Re: Loading a lot really small BMP files. -> Memory problems - 04/11/12 15:12

Or you could store them as BMP's, but read them into memory using 'file_load'
and just pull the data straight from the memory block...
Posted By: Damocles

Re: Loading a lot really small BMP files. -> Memory problems - 04/11/12 15:51

In Java I would load the images raw into a bytearray, attaching each bitmap after each other.
Then read them out and recreate them when needed.

(a custom Run-Lenght-Encoding could help compressing it if the bitmaps are relatively plain)

You could do the same in Lite-C:

look into the following points

#1 way to load data into an bytearray
#2 recreating a usable bitmap from an bytearray
#3 a sufficiently fast way to access the bitmaps (offsettable)
© 2024 lite-C Forums