CV++ RGB组数转为HBITMAP

char Drawbit[RGB]={... ...}

BITMAPINFOHEADER bih;
BITMAPINFO bi;
HBITMAP m_hBitmap;
memset(&bih,0,sizeof(BITMAPINFOHEADER));
memset(&bi,0,sizeof(bi));
bih.biBitCount= 24;
bih.biHeight= height;
bih.biPlanes= 1;
bih.biSize= 40;
bih.biWidth= Width;
bi.bmiHeader= bih; 

HDC hdc= GetDC( NULL ); 
m_hdc=CreateCompatibleDC(hdc);
m_hBitmap=CreateDIBSection(hdc,&bi,DIB_RGB_COLORS,(void**)&Drawbit,NULL,0);
memcpy(Drawbit, picbit, size);//图像数据给Drawbit
m_hBitmap=(HBITMAP)SelectObject(m_hdc,m_hBitmap);
BitBlt(hdc,0,0,Width,height,m_hdc,0,0,SRCCOPY);
m_hBitmap=(HBITMAP)SelectObject(m_hdc,m_hBitmap);
DeleteObject(m_hBitmap);
DeleteDC(m_hdc);

你可能感兴趣的:(C++图像处理)