The image data is in 8 bit binary in a file with the extension .bin
The file extension means nothing. What is important is for you to know the layout of this "bin" file. I can create a BMP file, put a ".bin" extension on it, and it is just as valid as what you're describing.
I installed a program called IrfanView that can be used to view images. However, IrfanView does not support .bin files.
Then you need to know exactly what ".bin" means, because that is such a generic term, no software will know what it is without inspecting the file.
The IrfranView program is made to identify files by looking at their layouts. For example, all BMP files start with "BM", TIFF files start with "II" or "MM", JPEG files have their markers, etc. Your "bin" file follows none of the major file formats in terms of identification.
Therefore, I am looking for a way to convert the .bin file to .bmp
You can't convert anything until you get a formal description of this "bin" format. Things such as how the color information is stored, pixel information, etc.
Last edited by Paul McKenzie; January 3rd, 2012 at 06:56 PM.
As others have said, this "bin" file could be anything - for example, take a look here to see some examples of various file formats that all use the bin extension (just something I googled up). The thing about extensions is that they can be anything regardless of the actual file type.
So, the first thing to do is to tell us where did you get this file, and what app created it.
You also might want to take a look at this, as it seems that Picasa can open some "bin" image file format, created by some Wii games (in-game screenshots).
I modified the existing code to convert my binary grayscale image. I was abled to create a BMP file. However, the color code is not correct. I believe that I did not set the color table. If anyone knows how to set the color table for the 8-bit grayscale, please help.
... I still have a problem to call the function DrawGrayScale from the "main" because I don't know what CDC and HANDLE are.
It is because "main" was not designed to draw something from within it.
In Windows you should draw anything in the response of WM_PAINT message.
So what you need is a GUI project (Win32 or MFC) where you will handle WM_PAINT message or override OnPaint (or OnDraw in the case of MFC SDI/MDI apps) and make your drawing...
I created a GUI project via MFC. I was able to draw my data on a window. But my old (main) program has lots of signal processing code. Therefore, I cannot abandon it. Do I have to transfer all the code in main to OnDraw procedure?
I wrote a C++ program where the main reads several binary-image input files and process them. The output is an array of binary data. I want to store this data in a bitmap grayscale file and display it.
According to your instruction, I created a MFC GUI and manually enter the data. But this GUI is independent from my main program. Do I have to abandon my main and move all of the logic from main to OnDraw?