I've been reading image files in double pointer arrays. ie:
BMP(char *fn, int no )
{
ifstream in(fn,ios::binary);
in.read((char*)&header,sizeof(header));
width=(int)(header[21]<<24|header[20]<<16|header[19]<<8|header[18]);
height=(int)(header[25]<<24|header[24]<<16|header[23]<<8|header[22]);
cout<<"Height:"<<height<<" Width:"<<width<<'\n';
in.read((char*)&plt,sizeof(plt));
clrs=new unsigned char[width*height];
in.read((char*)clrs,width*height);
in.close();
rollNo = no;
}
The problem I'm facing is that, it reads color values from 0 to 255 as per grey-scale readings.
void showOne ()
{
for ( int i = 0 ; i < width*height ; i++ )
{
int val1 = clrs[i];
cout << "\t\t index : " << i << " :\t\t" << val1 << endl;
}
}
Can anyone tell me how can I convert that reading into a Hexadecimal value, or yet, any other way so that RGB values could be distinguished?