Original Post
HI! First of all, I would like to apologize for my bad english. I'll try my best to explain my problem. Me and my pal have been working on a software rasterizer as a school project for over a half year now. we are working on a simple texturemapper at the moment and are trying to load a bitmap into an array and display it. I found the How to Load a Bitmap tutorial on gamedev, which helped us a lot, but still theres one problem... We've loaded the bitmap and draws it on the screen using gdi and the array that contains the actual picture. but the rgb colorvalues loaded from the bitmap isn't equal to the ones in the actual bitmapfile. ill include the code for my loading function below: int LoadBMP(char filename[], HDC hDC) { BITMAPFILEHEADER bmfh;//bitmapsfilhuvud BITMAPINFOHEADER bmfi;//bitmapsfilinfo fstream fin; fin.open(filename, ios::in|ios::binary); //öppna bitmapsfilen if(!(fin.read((char*)&bmfh, sizeof(bmfh)))) cout << "fel"; if(!(fin.read((char *)&bmfi, sizeof(bmfi)))) cout << "fel i läsandet av bmfi!" << endl; int dataSize = (bmfi.biWidth*bmfi.biHeight*(unsigned int)(bmfi.biBitCount/8.0)); char* ImageBitmap = new char[dataSize]; cout << dataSize << "b stor fil" << endl; cout << sizeof(ImageBitmap) << endl; fin.read((char*)ImageBitmap, (unsigned int)ImageBitmap); cout << "R: " << (int)ImageBitmap[5] << " G: " << (int)ImageBitmap[4] << " B: " << (int)ImageBitmap[3] << endl; if(ImageBitmap == NULL) { cout << "fuck"; } fin.close(); cout << "Bitmaptype: " << bmfh.bfType << endl; cout << "Storlek: " << bmfi.biSizeImage << " bytes" << endl; cout << "Bitdjup: " << bmfi.biBitCount << " bpp" << endl; cout << "Hojd(i pixlar): " << bmfi.biHeight << " px" << endl; cout << "Bredd(i pixlar): " << bmfi.biWidth << " px" << endl; int trace = 0; for(int y = 0; y < bmfi.biHeight; y++) { for(int x = 0; x < bmfi.biWidth ; x++) { SetPixel(hDC, x, y, RGB(SIGN((int)ImageBitmap[trace + 2]), SIGN((int)ImageBitmap[trace + 1]), SIGN((int)ImageBitmap[trace]))); trace += 3; } } SetPixel(hDC, 125,125, RGB(255,255,255)); ofstream fout; fout.open("BMPTEXT.txt", ios_base::out); trace = 0; for(int h = 0; h < bmfi.biHeight; h++) { for(int w = 0; w < bmfi.biWidth ; w++) { fout << "<" << (int)ImageBitmap[trace + 2] << "," << (int)ImageBitmap[trace + 1] << "," << (int)ImageBitmap[trace] << ">"; trace += 3; } fout << endl; } fout.close(); delete ImageBitmap; return 1; } I would be very happy if someone could tell me why my rgb values are wrong. it's hard to find a good tutorial on plotting bitmaps onto a screen. As most of you know, I can't use bitblt() because it doesn't work with texture interpolation. If anyone knows of any good tutorials on the topic you're welcome to post them:)