I'm trying to make a C++ console app that can convert binary(m开发者_Go百科p3) files to images. How can I read every binary character in the file, convert to hex, and then save it as an image. Here is what I want but in C++
You might find this tutorial helpful:
http://www.cplusplus.com/doc/tutorial/files/ (Scroll down to the section binary files)
Also, let me share my standard recommended links for people asking for aid on basic c++:
Full scale tutorial on c++
C++ Language Reference (including STL)
ANSI C Language reference for all those pesky C stuff that C++ keeps using
- Create an image with an area big enough to fit the data in.
- For each byte in the source file, set a pixel. You could do this a number of ways - monochrome, or take bytes in threes and write them as red, green and blue for a 24-bit colour image.
- Save the image to disk, e.g. in PNG format using libpng.
If you want a more specific answer, you'll need to ask a more specific question.
精彩评论