Kód:
int Device::Analyze()
{
int width, height, bits, pitch, tempBitmapID;
int rValue;
char* tempBitmap = (char*) malloc((this->width * ((this->bits + 1) / 8) + 0) * this->height);
if(rValue = is_CopyImageMem(*this->cameraHandlePointer, imgMemory, imgMemoryID, tempBitmap) != IS_SUCCESS)
return rValue;
if(is_InquireImageMem (*this->cameraHandlePointer, imgMemory, imgMemoryID, &width ,&height, &bits, &pitch) != IS_SUCCESS)
return rValue;
else
{
...
BITMAPINFO Bmi={0};
Bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
Bmi.bmiHeader.biWidth = width;
Bmi.bmiHeader.biHeight = height;
Bmi.bmiHeader.biPlanes = 1;
Bmi.bmiHeader.biBitCount = bits;
Bmi.bmiHeader.biCompression = BI_RGB;
Bmi.bmiHeader.biSizeImage = width*height*bits/8;
HDC hDc = GetDC(this->analyzeWindowHandle);
HDC chDc = CreateCompatibleDC(hDc);
HBITMAP hBmp = CreateCompatibleBitmap(hDc, width, height);
if(SetDIBits(chDc, hBmp, 0, height, tempBitmap, &Bmi, DIB_RGB_COLORS) == ERROR_INVALID_PARAMETER)
return 0;
BOOL ok = BitBlt(hDc,0,0,width,height,chDc,0,0,SRCCOPY);
DWORD d = GetLastError();
}
return 0;
}
V PictureBox-e sa mi nezobrazi nic. Pritom GetDC, CreateCompatibleDC aj HBITMAP mi vrati normalne handle. SetDIBits mi vrati 576 co je vlastne height a BitBlt mi vrati true... Tak troska nerozumiem, kde je problem?
// pridané po 14 hodinách 9 minútach od posledného príspevku Vyriesene
Kód:
int Device::Analyze()
{
int width, height, bits, pitch, tempBitmapID;
int rValue;
char* tempBitmap = (char*) malloc((this->width * ((this->bits + 1) / 8) + 0) * this->height);
if(rValue = is_CopyImageMem(*this->cameraHandlePointer, imgMemory, imgMemoryID, tempBitmap) != IS_SUCCESS)
return rValue;
if(is_InquireImageMem (*this->cameraHandlePointer, imgMemory, imgMemoryID, &width ,&height, &bits, &pitch) != IS_SUCCESS)
return rValue;
else
{
...
/**/
BITMAPINFO Bmi={0};
Bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
Bmi.bmiHeader.biWidth = width;
Bmi.bmiHeader.biHeight = height;
Bmi.bmiHeader.biPlanes = 1;
Bmi.bmiHeader.biBitCount = bits;
Bmi.bmiHeader.biCompression = BI_RGB;
Bmi.bmiHeader.biSizeImage = width*height*bits/8;
HDC hDc = GetDC(this->analyzeWindowHandle);
HDC chDc = CreateCompatibleDC(hDc);
HBITMAP hBmp = CreateCompatibleBitmap(hDc, width, height);
int res = (int) SelectObject(chDc,hBmp);
if(SetDIBits(chDc, hBmp, 0, height, tempBitmap, &Bmi, DIB_RGB_COLORS) == ERROR_INVALID_PARAMETER)
return 0;
//BitBlt(hDc,0,0,width,height,chDc,0,0,SRCCOPY);
StretchBlt(hDc,0,0,438,329,chDc,0,0,width,height,SRCCOPY);
}
return 0;
}
Vdaka za pomoc