nitinkale
asked on
Saving a bitmap on file
Hi ALL !!!
Last 2 days I'm struggling to save the bmp on the file.The main problem with my code is when I use DIBSECTION structure to get the values of the bmp structures the value obtained are correct but when I use BITMAPINFO structure the value are incorrect. I am refferencing DIBLLOKEX code which is on codeguru site for saving the bmp. Every other things are proper(size, height, width of the saved bmp) except that when i open this saved file it shows only a block rectangle of the same size that of the bmp which i saved.
I guess this is because the bit values are not correctly stored. Can anybody tell me how to get the bit values from the DIBSECTION structure? I've tried "GetBitmapBits" API but still giving the same problem.
The bitmap is 256 bits.
Thanks in advance
Nitin
Last 2 days I'm struggling to save the bmp on the file.The main problem with my code is when I use DIBSECTION structure to get the values of the bmp structures the value obtained are correct but when I use BITMAPINFO structure the value are incorrect. I am refferencing DIBLLOKEX code which is on codeguru site for saving the bmp. Every other things are proper(size, height, width of the saved bmp) except that when i open this saved file it shows only a block rectangle of the same size that of the bmp which i saved.
I guess this is because the bit values are not correctly stored. Can anybody tell me how to get the bit values from the DIBSECTION structure? I've tried "GetBitmapBits" API but still giving the same problem.
The bitmap is 256 bits.
Thanks in advance
Nitin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can store simply and directly by converting your HBITMAP to a DIB in a memory block, then storing the memory block to a file. DIB format is the same whether in memory or in a file, since it is device independent.
Let me know if you need working code.
David
Let me know if you need working code.
David
>> The bitmap is 256 bits
I guess you mean 256 colors.
I asked for the color depth because if you use 256 colors then you'll have to store a color palette in your bitmap file.
Maybe you wrote an "empty" palette to the file.
I guess you mean 256 colors.
I asked for the color depth because if you use 256 colors then you'll have to store a color palette in your bitmap file.
Maybe you wrote an "empty" palette to the file.
You can check this by viewing the file with hex editor.
What is the color depth of the bitmap ?