Store the indivivual bits & data of a bitmap in member variables?
Hi there! I wanna create my own custom file format which em-beds and holds a bitmap image and some text within the file.(let''s call it .abc)
When the user serializes(saves) the file, I wanna store the data bits and information about the bitmap in member variables, so that when the file is saved, the file size will be much much lighter, cos'' the bitmap isn''t physically saved to disk, just the information about the bitmap, so that when the user clicks the Open menu item, the bitmap bits and information are read and united into a bitmap at run-time.
I''m willing to pay US$$$s if anyone can help me to solve this problem. Thanks! :-D
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone's watching in awe......."
I don''t understand. Are you saying you want to save a bitmap without actually saving it? Good luck trying to do that. Maybe I misunderstood you though. If you want to save space, make your graphics format use some type of compression.
If what you mean is bitpacking, then that''s relatively easy. You could use something like this:
Then, instead of saving many, many bools to disk, you save bit-packed unsigned chars to disk, accessing the individual bits as I do above.
However, I''m not sure if that''s what you want. Do you want to store, instead, something to recreate an image, like this?
Circle{radius=3; x=2; y=1; color=#00ff00}
Rectangle{x=10, y=82, width=72, height = 98; color="#FF0055"}
Gaussian_Blur{radius=10}
Text{x=7; y=89; size=14; font="Arial"; string="Hello!"}
...but in a binary format? If so, I don''t really know how to help you. I don''t really have experience with binary file i/o.
|
Then, instead of saving many, many bools to disk, you save bit-packed unsigned chars to disk, accessing the individual bits as I do above.
However, I''m not sure if that''s what you want. Do you want to store, instead, something to recreate an image, like this?
Circle{radius=3; x=2; y=1; color=#00ff00}
Rectangle{x=10, y=82, width=72, height = 98; color="#FF0055"}
Gaussian_Blur{radius=10}
Text{x=7; y=89; size=14; font="Arial"; string="Hello!"}
...but in a binary format? If so, I don''t really know how to help you. I don''t really have experience with binary file i/o.
quote:
When the user serializes(saves) the file, I wanna store the data bits and information about the bitmap in member variables, so that when the file is saved, the file size will be much much lighter, cos'' the bitmap isn''t physically saved to disk, just the information about the bitmap,
Are you lucid?
Magmai Kai Holmlor
- Not For Rent
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Hi there again! My custom file format will be like :
.abc file format :
___________________________
| |
|Bitmap''s data bits |
| |
|___________________________|
The above is a graphical representation of the file format. First, it''s the indivivual data bits of the bitmap, and then the CString object itself.
So, that means, when run, the program works like this

1) The user starts up the program, and the program can open bitmap and .abc files.
2) The user loads a bitmap from the hard disk by choosing the Open menu item. The bitmap is shown on the view.
3) The user clicks the Save menu item. Here, the Document''s OnSerialize(....) function gets called. The code would look something like this:
CMyDocument::OnSerialize(CArchive &ar)
{
if(ar.IsStoring())
{
ar << m_Bitmap.biSize;
ar << m_Bitmap.biPlanes;
.
.
.
}
}
So, as u can see, instead of writing and saving the bitmap to disk as a bitmap file, I just wanna store the bitmap''s indivivual fields and bits and information in the .abc file format.
So, that means when the .abc file is saved, it just contains the chosen bitmap''s data members and related bits and information, so that when the user uses the same program to open this .abc file, we can use a bitmap creating function like CreateBitmap() or CreateBitmapIndirect() etc to create the same bitmap, by filling in the required parameters and structures with the bitmap information and data members that is saved into the .abc file earlier on.
So, as u can see, because the bitmap isn''t saved as a bitmap file but just the information about the bitmap is stored, the .abc file will be much much smaller, but is able to create a bitmap from all the bitmap''s data previously stored.
Thanks a lot and please help! :-D
Xeon.
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone's watching in awe......."
you''re only going to be saving a few bytes of space by knocking out the remaining unnecessary fields of a bitmap file. the bitmap file header contains nearly the bare bones info needed to load the bitmap. ideally, you would just want width, height, and bitdepth, and data, and pretty much everything else can be chucked.
this leaves you removing just a few data members of the BITMAPFILEHEADER/BITMAPINFOHEADER structures. not much compression.
if you really wanna use compression, look into jpeg encoding. however, this is inadvisable for loading game bitmaps. you could simply use a basic run length encoding algorithm. that should "sorta" add some compression, given that the images are not "too" complex. but like i said before, removing a few data members from the bitmap structures is not going to save you much more space than with a regular bitmap, though it IS nice to create your own file format =).
a2k
this leaves you removing just a few data members of the BITMAPFILEHEADER/BITMAPINFOHEADER structures. not much compression.
if you really wanna use compression, look into jpeg encoding. however, this is inadvisable for loading game bitmaps. you could simply use a basic run length encoding algorithm. that should "sorta" add some compression, given that the images are not "too" complex. but like i said before, removing a few data members from the bitmap structures is not going to save you much more space than with a regular bitmap, though it IS nice to create your own file format =).
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
Hi there! Do u know how to save the JPEG file format within my own file format? Thanks!(do help!)
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone's watching in awe......."
Hi again! Does anyone knows how to save/load files in the JPEG file format? I know there''s lottsa sample programs out there, but either they don''t give out the source code, or I''ve trouble integrating into my own file format. If u know how to load and save in the JPEG file format, please reply, and I''ll send you my current project(very simple, pals) and we can discuss further. Also, I''ll pay u $$$ if there''s a need. :-D
Good luck and please reply soon.
Xeon.
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone's watching in awe......."
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement