图像数据在线程里面绘制Picture控件

void  show(CMFCApplication1Dlg  * pThis, UINT  ID,unsigned char * datam , int nBitCount) {
   
    HWND g_hwnd =  GetDlgItem(pThis->m_hWnd,ID);

	CDC * m_cdc = pThis->GetDlgItem(ID)->GetDC();

	HDC  hdc = m_cdc->GetSafeHdc();	 

	CRect rc;
	
	GetClientRect(g_hwnd, &rc);
	 
	HDC hdcBmp = CreateCompatibleDC(hdc);

	int sz= sizeof(BITMAPINFOHEADER); 

	BITMAPINFO *bitInfo = (BITMAPINFO*)new  BYTE[sz]; 

	bitInfo->bmiHeader.biBitCount = 8 * nBitCount;      //单通道 8*1 3通道 8*3

	bitInfo->bmiHeader.biWidth = pThis->Image_Parm->width;  //宽

	bitInfo->bmiHeader.biHeight = -pThis->Image_Parm->height; //高

	bitInfo->bmiHeader.biPlanes = 1;

	bitInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);

	bitInfo->bmiHeader.biCompression = BI_RGB;
 
	HBITMAP hbmp = ::CreateDIBitmap(hdc, &bitInfo->bmiHeader, CBM_INIT, datam,  bitInfo, DIB_RGB_COLORS);
 
	SelectObject(hdcBmp, hbmp);
	SetStretchBltMode(hdc, HALFTONE);
	 
	StretchBlt(hdc, 0, 0, rc.right, rc.bottom, hdcBmp, 0, 0, pThis->Image_Parm->width, pThis->Image_Parm->height, SRCCOPY);
	DeleteObject(hbmp);
	DeleteDC(hdcBmp);
	ReleaseDC(g_hwnd, hdc); 
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值