problems with getting RGB values
-
Hello i have been trying to get RGB values from a 24bit BITMAP following is the code : bitmap = (HBITMAP)LoadImage(NULL,path,IMAGE_BITMAP,0,0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); ::GetObject(bitmap,sizeof(bm),&bm); BYTE *pix = (BYTE*) bm.bmBits; //bm is of type BITMAP pixels pixel[216][331]; //file opened is 216 * 331 CClientDC dc(this); int k = 0; for(int j = 0; j <= height-1 ; j ++) { for(int i = 0; i <= width-1; i ++) { pixel[j][i].blue = pix[k++]; pixel[j][i].green = pix[k++]; pixel[j][i].red = pix[k++]; dc.SetPixel(i,j,RGB(pixel[j][i].red,pixel[j][i].green,pixel[j] [i].blue)); } } I am trying to figure out the problem i cant find it help me please the result that is displayed is not the correct image i mean its all inverted and rotated i dont understand the pixels values are there how to ARRANGE them please help me out
-
Hello i have been trying to get RGB values from a 24bit BITMAP following is the code : bitmap = (HBITMAP)LoadImage(NULL,path,IMAGE_BITMAP,0,0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); ::GetObject(bitmap,sizeof(bm),&bm); BYTE *pix = (BYTE*) bm.bmBits; //bm is of type BITMAP pixels pixel[216][331]; //file opened is 216 * 331 CClientDC dc(this); int k = 0; for(int j = 0; j <= height-1 ; j ++) { for(int i = 0; i <= width-1; i ++) { pixel[j][i].blue = pix[k++]; pixel[j][i].green = pix[k++]; pixel[j][i].red = pix[k++]; dc.SetPixel(i,j,RGB(pixel[j][i].red,pixel[j][i].green,pixel[j] [i].blue)); } } I am trying to figure out the problem i cant find it help me please the result that is displayed is not the correct image i mean its all inverted and rotated i dont understand the pixels values are there how to ARRANGE them please help me out