A C++ to program for RGB


#include<iostream>
#include<fstream.h>
#include<conio.h>
#include<string.h>
#include<math.h>
using namespace std;
struct pix
{
unsigned char b,g,r;
}pixel;
char Header[54];
ifstream in;
ofstream out,out1;
int main()
{
char infile[]=”d:\\lena.bmp”;
int i,j;
i=j=0;
in.open(infile,ios::in|ios::binary);
in.read((char*)(&Header),sizeof(Header));
while(!in.eof())
{
in.read((char*) (&pixel),sizeof(pixel));
cout<<“\n”<<(int)pixel.r<<” “<<(int)pixel.g<<” “<<(int)pixel.b;
}
in.close();
getch();
}