zoukankan      html  css  js  c++  java
  • MFC Picture控件加载图片

    	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
    height = %d
    ", 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);
    

     使用CImage绘制PNG图片

            CDC *pDC = GetDC();
    	CImage Image;
    	Image.Load(_T("C:/C_Project/MFCApplication1/Debug/flow.png"));
    	if (Image.IsNull())
    	{
    		MessageBox(_T("没加载成功"));
    	}
    	if (Image.GetBPP() == 32)
    	{
    		for (int i = 0; i < Image.GetWidth(); i++)
    		{
    			for (int j = 0; j < Image.GetHeight(); j++)
    			{
    				byte *pByte = (byte*)Image.GetPixelAddress(i, j);
    				pByte[0] = pByte[0] * pByte[3] / 255;
    				pByte[1] = pByte[1] * pByte[3] / 255;
    				pByte[2] = pByte[2] * pByte[3] / 255;
    			}
    		}
    	}
    	Image.Draw(pDC->m_hDC, 0, 0);
    

      

  • 相关阅读:
    Qt应用如何发布
    关于在windows下部署发布QT程序的总结
    干净地发布QT程序
    解析 Qt 程序在Windows 下发布
    Qt 5.2.0 和 VS 2012集成
    Unable to find a qt build, to solve this problem specify a qt build
    运行python程序不显示cmd的方法
    py2exe使用方法
    python 类
    在Pygtk和Glade使用Gtkbuilder
  • 原文地址:https://www.cnblogs.com/mypsq/p/5956066.html
Copyright © 2011-2022 走看看