Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Png file as wallpaper Collapse All
Subject Author Date
himanshu joshi Mar 7, 2007 - 12:10 AM

Hi

I have a bitmap loaded as wallpaper(Background image) of my application
Could you suggest how to load a .png file as wallpaper to my application

Thanks
Himanshu

Technical Support Mar 7, 2007 - 12:49 PM

You can learn how to load a png image from this article. Now the question is how to draw the loaded image. In the CExtBitmap class there is a CExtBitmap::AlphaBlend() method, which paints such a bitmap on any Windows OS. There are several overloads of this method so you can use any of them.

himanshu joshi Mar 8, 2007 - 5:39 AM

Hi

To load a png file i have to use CExtSkinBitmap Object.
Does this support AlphaBlend method and which overloaded version of this function should we use

Thanks

Technical Support Mar 9, 2007 - 8:24 AM

The CExtSkinBitmap class is a simple extension of CExtBitmap, which allows you load PNG images from a file on disk or from resources. So you can use any method of CExtBitmap as well. You can use that overloaded version that best meets your particular needs. The simplest version of AlphaBlend() requires only a handle to the device context and a destination rectangle that specifies where the image should be drawn.



himanshu joshi Mar 12, 2007 - 2:27 AM

thanks

i have used following code to do the same

CExtSkinBitmap pBitmap;
LPCTSTR strPngImageResourceID;
LPCTSTR strPngResourceSection;
HRSRC hRsrc;
CRect rectInside;
GetClientRect(rectInside);
strPngImageResourceID = MAKEINTRESOURCE(IDB_SPLASHR2);
strPngResourceSection = _T("PNG");
hRsrc = ::FindResource(AfxGetInstanceHandle(), strPngImageResourceID, strPngResourceSection );
ASSERT(hRsrc);
VERIFY(pBitmap.LoadPNG_Resource(AfxGetInstanceHandle(),hRsrc));
HDC hDc= ::GetDC(AfxGetMainWnd()->m_hWnd);
pBitmap.AlphaBlend(hDc,&rectInside,255);

still i am getting error AlphaBlend dos not take 3 arguments
Could you please correct the code if something is missing.

Thanks and Regards
Himanshu

Technical Support Mar 13, 2007 - 3:48 AM

Here are all the AlphaBlend() overrides. You can find their descriptions in the documentation.

virtual int AlphaBlend(
    HDC hDC,
    int nDstX,
    int nDstY,
    int nDstWidth,
    int nDstHeight,
    int nSrcX,
    int nSrcY,
    int nSrcWidth,
    int nSrcHeight,
    BYTE nSCA = 0xFF
    ) const;
int AlphaBlend(
    HDC hDC,
    int nDstX,
    int nDstY,
    int nDstWidth,
    int nDstHeight,
    BYTE nSCA = 0xFF
    ) const;
int AlphaBlend(
    HDC hDC,
    const RECT & rcDst,
    const RECT & rcSrc,
    BYTE nSCA = 0xFF
    ) const;
int AlphaBlend(
    HDC hDC,
    const RECT & rcDst,
    BYTE nSCA = 0xFF
    ) const;