//--------------------------------------------MyPaint() 函数---------------------------------------------------
//绘制图形
//-------------------------------------------------------------------------------------------------------------
void MyPaint(HDC hdc)
{
CImage m_Image;
// 获取CImage支持的图像文件的过滤字符串
/*hResult = m_Image.GetExporterFilterString(strFilter, aguidFileTypes,
_T("All Image Files"));*/
//释放CImage对象
m_Image.Destroy();
// 将外部图像文件装载到CImage对象中
m_Image.Load("1.jpg");
m_Image.Draw(hdc, 0, 0);

m_Image.Destroy();
m_Image.Load("1.png");
m_Image.Draw(hdc, 100, 50);

//PNG透明显示的方法
m_Image.Destroy();
m_Image.Load("3.png");
m_Image.TransparentBlt(hdc, 200, 300, m_Image.GetWidth(), m_Image.GetHeight(), RGB(255, 255, 255));

//PNG半透明显示(前提是图片也是半透明的)
m_Image.Destroy();
m_Image.Load("4.png");
for (int i = 0; i < m_Image.GetWidth(); ++i)
{
for (int j = 0; j < m_Image.GetHeight(); ++j)
{
unsigned char* pucColor = (UCHAR*)m_Image.GetPixelAddress(i, j);
pucColor[0] = pucColor[0] * pucColor[3] / 255;
pucColor[1] = pucColor[1] * pucColor[3] / 255;
pucColor[2] = pucColor[2] * pucColor[3] / 255;
}
}
m_Image.AlphaBlend(hdc, 300, 300);

}

 

如需整体运行框架,请点击: 游戏框架

游戏开发的梦想

梦开始的地方

posted on 2015-11-21 22:51  zishen  阅读(578)  评论(0编辑  收藏  举报