Witam,
napisalem funkcje w winapi, ktora wczytuje bity z bitmapy (24 bit) do macierzy. Kompiluje sie, ale niestety dziala niepoprawnie-zwraca zle wartosci. Nie moge znalezc bledu. Oto kod:
int*** LoadBMPfromClipboard(HBITMAP hBMP,HDC hDC)
{
HANDLE hf; // file handle
BITMAPFILEHEADER hdr; // bitmap file-header
PBITMAPINFOHEADER pbih; // bitmap info-header
LPBYTE lpBits; // memory pointer
DWORD dwTotal; // total count of bytes
DWORD cb; // incremental count of bytes
BYTE *hp; // byte pointer
DWORD dwTmp;
PBITMAPINFO pbi;
pbi=CreateBitmapInfoStruct(hBMP);
int height,width,depth;
pbih = (PBITMAPINFOHEADER) pbi;
lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);
//!
// errhandler(“GlobalAlloc”, hwnd);
// Retrieve the color table (RGBQUAD array) and the bits
// (array of palette indices) from the DIB.
GetDIBits(hDC, hBMP, 0, (WORD) pbih-biHeight, lpBits, pbi,
DIB_RGB_COLORS);
/*
DIB_RGB_COLORS))
{
errhandler(“GetDIBits”, hwnd);
}
*/
width = pbi-bmiHeader.biWidth;
height = pbi-bmiHeader.biHeight;
depth = 24;
//////make an array
int ***array;
array = new int **[height];
for(int i=0;i
array = new int*[width];
for(int i=0;i
for(int j=0;j
{
// if( depth == 1)
// array_[j]= new float[1];_
// else if(depth == 32)
// array_[j]= new float[4];_
// else if(depth == 24)
array_[j]= new int[3];_
}
//////put JPEG to array
hp = lpBits;
for(int i=0;i
for(int j=0;j
{
/* if( depth == 1)
{
}
else if(depth == 32)
{
} */
//else if(depth == 24)
//{
array_[j][0]= *hp++;_
array_[j][1]= *hp++;_
array_[j][2]= *hp++;_
//}
}
return array;
}
Z gory dziekuje za pomoc.
Pozdrawiam