nebkat
nebkat

Reputation: 8565

C++ Convert Binary File to Image

I'm trying to make a C++ console app that can convert binary(mp3) 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++

Upvotes: 2

Views: 6046

Answers (2)

sum1stolemyname
sum1stolemyname

Reputation: 4552

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

Upvotes: 1

AshleysBrain
AshleysBrain

Reputation: 22591

  1. Create an image with an area big enough to fit the data in.
  2. 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.
  3. 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.

Upvotes: 0

Related Questions