EasyBMP icon indicating copy to clipboard operation
EasyBMP copied to clipboard

Image(i,j)->Red is not working

Open Nomad-Learner opened this issue 2 years ago • 0 comments

I saw the page https://bytes.com/topic/c/answers/580148-bitmap-hexadecimal-conversion

It told me that if I use

cout << "red: " << Image(i,j)->Red << "\t" << "green: " << Image(i,j)->Green << "\t" << "blue: " << Image(i,j)->Blue << endl;

   this code, I will get R/G/B value of bmp file

but it is not work.

this is my code. when I use Image(i,j), It works but when I use Image(i,j)->Red it is not work

#include "EasyBMP.h" #include using namespace std;

int main() { ofstream fout; fout.open("long.hex"); BMP Image;

Image.ReadFromFile("test_red.bmp");

for (int j = 0; j < Image.TellHeight(); j++)
{
	for (int i = 0; i < Image.TellWidth(); i++)
	{
		fout << hex << Image(i, j) << endl;
	}
	cout << endl;
}

//for (int j = 0; j < Image.TellHeight(); j++)
//{
//	for (int i = 0; i < Image.TellWidth(); i++)
//	{
//		cout << Image(i, j)->Red << "\t"
//			<< Image(i, j)->Green << "\t"
//			<< Image(i, j)->Blue << endl;
//	}
//	
//}

return 0;

}

this is what happen. ques

Nomad-Learner avatar Mar 23 '22 07:03 Nomad-Learner