here use my function here:
now here is an example how you call itCode:// hwnd = handle to the image control // W = width of the raw bits Image // H = height of the raw bits Image // lpBits = pointer to the raw bits image // BitCount = 32,24 etc ( depend on the bit count ) defualt =32 void SetRawBitsToImage (HWND hwnd,int W,int H,BYTE *lpBits, int BitCount =32 ) { HDC hDC = ::GetDC(hwnd); ::SetWindowPos(hwnd,0,0,0,W,H,SWP_NOMOVE); BITMAPINFO bi; memset(&bi,0,sizeof(BITMAPINFO)); bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bi.bmiHeader.biWidth = W; bi.bmiHeader.biHeight = H; bi.bmiHeader.biPlanes = 1; bi.bmiHeader.biBitCount = BitCount; bi.bmiHeader.biCompression = BI_RGB; bi.bmiHeader.biSizeImage = bi.bmiHeader.biWidth*bi.bmiHeader.biHeight*BitCount/8; ::SetDIBitsToDevice(hDC, 0,0, W, H, 0, 0, 0,bi.bmiHeader.biHeight, lpBits,&bi,DIB_RGB_COLORS); ::ReleaseDC(hwnd,hDC); }
now in my sample i just created garbaged image and i display it, you should provide the real image, i dont know if you have the bitmap raw bits you can get them by ::GetBitmapBits(..) api.Code:HWND hImage = this->GetDlgItem(IDC_S)->GetSafeHwnd(); BYTE *Image = new BYTE[100*100*4]; // empty image SetRawBitsToImage (hImage,100,100,Image ,32);
and in order to load bitmap from disc use the ::LoadImage(..) api.
hope its covers what you need.
Cheers




Reply With Quote