类CImage,头文件atlimage.h
1.显示背景透明的PNG图片
CImage m_Image;
m_Image.Load(图片路径);//装载图片
for(int i = 0; i < m_Image.GetWidth(); i++)
{
for(int j = 0; j < m_Image.GetHeight(); j++)
{
unsigned char* pucColor = reinterpret_cast<unsigned char *>(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.Draw(...)显示图片
BOOL CImage::Draw( HDC hDestDC, int xDest, int yDest, int nDestWidth,
int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight )
2.显示整体半透明PNG图片
BOOL CImage::AlphaBlend( HDC hDestDC, int xDest, int yDest,
int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth,
int nSrcHeight, BYTE bSrcAlpha, BYTE bBlendOp )
bSrcAlpha=255表示图片整体不透明
bSrcAlpha=0表示整体透明