createdibsection

How to convert an Array of pixels to HBITMAP

坚强是说给别人听的谎言 提交于 2020-01-10 03:46:06
问题 I have an array of pixels which I need to convert to HBITMAP in order to display it in a window. I tried to use CreateDIBitmap() but I don't have the BMP headers. I tried to construct them manually according to MSDN documentation but this didn't work. Here how my code looks HBITMAP hBitmap char pixels[160*120]; // White grayscale image of size 160x120 memset(pixels,255,sizeof(pixels)); BITMAPINFOHEADER bmih; bmih.biSize = sizeof(BITMAPINFOHEADER); bmih.biWidth = 160; bmih.biHeight = -120;

CreateDIBSection failed

偶尔善良 提交于 2019-12-11 02:15:57
问题 BITMAPINFO bmi; memset(&bmi,0,sizeof(BITMAPINFO)); bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth =m_pImg->GetWidth(); bmi.bmiHeader.biHeight =m_pImg->GetHeight(); bmi.bmiHeader.biPlanes = 1; //if( m_pImg->GetInfo()->biBitCount!=16) //{ // bmi.bmiHeader.biBitCount = m_pImg->GetInfo()->biBitCount; //} //else //{ //ASSERT((m_pImg->GetInfo())->bmiHeader->biBitCount == 24); bmi.bmiHeader.biBitCount=24; bmi.bmiHeader.biCompression = BI_RGB; if (bmi.bmiHeader.biSizeImage ==

Understanding GetDiBits. C++

馋奶兔 提交于 2019-12-11 00:24:13
问题 MSDN says that the bitmap used in GetDiBits should not be selected into a DC before calling this function. But from my experience(with BitBlt ) I know that I cannot draw an a bitmap unless it is selected. How does GetDiBits circumvents this? Can I just use an unselected, newly created bitmap as argument to this function? GetDiBits as well CreateDibSection returns an array. But MSDN says about the first function: "bits of the specified compatible bitmap" I thought DI stands for