c++ 怎么给对话框添加背景图片?

网上看的一种方法是通过“插入资源”来添加JPG图片,后面的操作就不会了!好像是什么控件?

用CImage类.

在onpaint()中
if (IsIconic())
{
 .......//系统代码,不修改
}
else    //在else中增加如下代码,对JPG,BMP,PNG(背景透明图片)有效
{
    CRect rc;
    GetClientRect(rc);
    CImage image;
    image.Load(_T("c:\\1.jpg")); //图片文件路径
    if (image.GetBPP() == 32)
    {
        int i; int j; 
        for (i = 0; i < image.GetWidth(); i++)
        {
            for (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(GetDC()->m_hDC, rc);
}

追问

GetWidth();  GetPixelAddress函数是要定义吧?编译不通过!

追答

这些是CImage类中的成员函数啊

追问

vc6.0里面没有atlimage.h库文件

温馨提示:答案为网友推荐,仅供参考
相似回答