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);
//!!!! if (!lpBits)
// 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);
/*!!!! if (!GetDIBits(hDC, hBMP, 0, (WORD) pbih->biHeight, lpBits, pbi,
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<height;i++)
array[i] = new int*[width];
for(int i=0;i<height;i++)
for(int j=0;j<width;j++)
{
// if( depth == 1)
// array[i][j]= new float[1];
// else if(depth == 32)
// array[i][j]= new float[4];
// else if(depth == 24)
array[i][j]= new int[3];
}
//////put JPEG to array
hp = lpBits;
for(int i=0;i<height;i++)
for(int j=0;j<width;j++)
{
/* if( depth == 1)
{
}
else if(depth == 32)
{
} */
//else if(depth == 24)
//{
array[i][j][0]= *hp++;
array[i][j][1]= *hp++;
array[i][j][2]= *hp++;
//}
}
return array;
}
Z gory dziekuje za pomoc.
Pozdrawiam
//q: wlaczylem formatowanie, ale to nic nie dalo.. spotkamy sie w koszu, ja tego re-formatowac za Ciebei nie bede