首页 > 编程语言 > 详细

MFC Picture控件加载图片

时间:2016-10-13 14:51:49      阅读:228      评论:0      收藏:0      [点我收藏+]
	CStatic *pPic = (CStatic*)GetDlgItem(IDC_PICTURE);
	CBitmap bitmap;
	bitmap.LoadBitmapW(IDB_BITMAP2);
	pPic->SetBitmap((HBITMAP)bitmap.GetSafeHandle());
//在Picture的Type调为Bitmap

  

像素修改:

	CStatic *pPic = (CStatic*)GetDlgItem(IDC_PICTURE);
	CBitmap bitmap;
	bitmap.LoadBitmapW(IDB_BITMAP2);
	BITMAP mBitmap;
	bitmap.GetBitmap(&mBitmap);

	HBITMAP hBitmap = (HBITMAP)bitmap.GetSafeHandle();

	CImage image;
	image.Attach(hBitmap);
	int mWidth = image.GetWidth();
	int mHeight = image.GetHeight();
	_cprintf("width = %d\nheight = %d\n", image.GetWidth(), image.GetHeight());
	for (int i = 0; i < mWidth; i++)
	{
		for (int j = 0; j < mHeight; j++)
		{
			if (i>=10&&i<=30)
			image.SetPixel(i, j, RGB(20,50,90));
		}
	}
	
	CDialogEx::OnPaint();
	CClientDC dc(this);//选定当前画图环境
	DrawLine(&dc);


	pPic->SetBitmap(hBitmap);

  

MFC Picture控件加载图片

原文:http://www.cnblogs.com/mypsq/p/5956066.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!