I apologize for the a question that may be considered "newbie," but I just started learning how to use c++. I know how to read and write text files, but if I want to open an image file, will it be the same as opening a normal text file, or is it different? I believe it is different because when I drag the file to CodeBlocks to just examine it, it just uses numbers. For example, row 4 is 13 33 66, and row 19 is 15 28 80.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream file_reader("file_name_example.ppm", ios::binary | ios::out);
if (! file_reader.is_open())
{
cout << "The file cannot open." << endl;
}
return 0;
I only want to change the blue value of the image, so I understand I will need to do a for-loop to do every third value (R G B). My question is how exactly do I do this? After I open the file, how to I replace every third number with another value?
I really appreciate any help. Thank you!