Conversion from BMP to binary file.. (Please help)
I am new member for this forum.
I want to convert to a BMP (24-bit) file in to binary format , then want to edit binary values in and again convert back to BMP file.
Is it possible, through c or c++ or any tool is available for this.
I am in a big need of this .
Please help. me...
A couple of suggestions...
Go to wotsit.org and download the BMP format spec.
Remember that everything in the computer's memory is already stored in binary. That means that once you've "decoded" the bitmap... once you have color-numbers for each pixel, you can perform binary-bitwise operations without any "conversion". (In fact, the most common text encryption technique is bitwise-exclusive-or, which is performed on ASCII values without any conversion.)
By default C++ hides the binary from you, by automatically converting number values to/from decimal, and ASCII values that represent characters to/from alpha-numeric characters. It's actually a bit tricky to directly use binary I/O with C++.
If you really need to "see" the binary representation, the normal way is to use hexadecimal. cin and cout can be used to input/output hex values directly. And, hex is much easier than binary (for humans) to read, especially if you're dealing with more than 16-bits. You can learn to convert between binary and hex in your head... Anybody studying Applied Optics can learn this in a couple of hours or less! :D Programmers (and hardware guys like me) almost always use hex, when working with binary numbers.
There is a standard C++ header called <bitset> which makes working with and displaying binary numbers easier.
Get a Hex Editor. I think some versions of Microsoft Visual Studio come with one, or you can download one from the Net. A hex editor will allow you to open a bitmap file (or any other file). It will show you the hex values of every byte, an it will allow you to maually edit the bytes.
Every hex editer I've seen will also display the ASCII character of every value that falls in the ASCII character range. (The hex editor doesn't "know" if a particular value is supposed to represent an ASCII character.)
I'm pretty sure there is a Windows API function (or other microsoft library function) for copying the bitmap pixels into an array. That way, you wouldn't have to write the code to decode the bitmap format. You might search MSDN or post a question on the Windows forum.