please wait
Where are you on these steps? 1) Python knowledge to simply read and write a binary file. Can you do this, like a float, an int, a string, write it out and read it back in, in binary? 2) learn a hex editor. Can you open the file you wrote in 1) above and read it in a hex editor to verify it, and to some extent see what is in the file? 3) study the png file format. Do you know what that looks like? How big is the image, where are the pixels, what time was it taken, ... etc? 4) start to work on the project, using 1,2, and 3 to do something? Start simple ... maybe read an image in, swap say all the blue and red in the pixels, write it back out, and look at it in an image program to see that you did indeed mess it up? |
ifstream::get()
. This is very easy to do and works just fine.std::string
or std::vector<std::byte>
or something, then you can pick at the pieces at your leisure.std::ios::binary
mode!std::vector<std::size_t>
of offsets into the file/stream/memory as you encounter them. That way you don’t have to search around for any specific chunk more than once. The PNG reader doesn’t really need to do that, though.
The two main ways to read the file are: ❶ Read byte-by-byte using something like ifstream::get(). This is very easy to do and works just fine. ❷ Read the whole thing into a std::string or std::vector<std::byte> or something, then you can pick at the pieces at your leisure. Both ways work just as well, and are ultimately equivalent, believe it or not (your reader can easily be written to work over both with maybe a single line of code different between the two). |
|
|
|
|
|
|
|
|
|
|