I want to write a function that can return the RGB value of a (x,y) pixel. I want it to change it to a string that is interpreted in *.html files. For example #000000 stands for black and #FFFFFF makes white but you probably already know that.
Yesterday I've written (with a little bit of help from my friend) this code:
I've created the bitmap and it works good because it return valid height, width and bits per pixel values. Have you got any idea about what my next step should be?Code:#include <iostream> #include <fstream> #include <windows.h> int main() { int Width = 0; int Height = 0; int BitCount = 0; ifstream bmpFile; BITMAPFILEHEADER bmpFileHead; BITMAPINFOHEADER bmpInfoHead; bmpFile.open("image.bmp", ios::binary | ios::in); if( !bmpFile.is_open() ) cout << "\nError loading image file."; else cout << "\nImage file loaded."; bmpFile.read( (char*)&bmpFileHead.bfType, 14 ); if(bmpFileHead.bfType!=0x4d42) // 0x4d42 is BM cout << "\nWrong file format."; bmpFile.read( (char*)&bmpInfoHead, sizeof(BITMAPINFOHEADER) ); if(bmpInfoHead.biCompression!=BI_RGB) cout << "\nSupports only BI_RGB files, sorry."; Width = bmpInfoHead.biWidth; Height = bmpInfoHead.biHeight; BitCount = bmpInfoHead.biBitCount; cout << "\nWidth: " << Width; cout << "\nHeight: " << Height; cout << "\nBits per pixel: " << BitCount; cin.get(); return 0; }



LinkBack URL
About LinkBacks



)