学习笔记 :mfc窗口显示png图片

void ShowImage(void* pImage)
{

	COleStreamFile osf;
	osf.CreateMemoryStream(NULL);
	osf.Write(pImage, 1024 * 10);
	osf.SeekToBegin();

	CImage image;
	if (SUCCEEDED(image.Load(osf.GetStream())))
	{
		auto pWnd = GetDlgItem(IDC_CODE);//这里是获得控件句柄
		CDC* pDC = pWnd->GetDC();
		HDC hDC = pDC->m_hDC;

		CRect rect_frame;
		pWnd->GetClientRect(&rect_frame);

		::SetStretchBltMode(hDC, HALFTONE);
		::SetBrushOrgEx(hDC, 0, 0, NULL);

		image.Draw(hDC, rect_frame);
		ReleaseDC(pDC);//释放picture控件的DC
	}
}

你可能感兴趣的:(MFC,学习笔记)