2013年5月1日 星期三

[Win32, C] Bitmap rendering translucent

BOOL AlphaBlend(
    HDC hdcDest,
    int nXOriginDest,
    int nYOriginDest,
    int nWidthDest,
    int nHeightDest,
    HDC hdcSrc,
    int nXOriginSrc,
    int nYOriginSrc,
    int nWidthSrc,
    int nHeightSrc,
    BLENDFUNCTION blendFunction
);

This function displays bitmaps that have transparent or semitransparent pixels.

Sample
    BLENDFUNCTION bf;
    bf.BlendOp = AC_SRC_OVER;
    bf.BlendFlags = 0;
    bf.SourceConstantAlpha = 127; // Transparency 0-255
    bf.AlphaFormat = 0;

    // hBmpDC for Transparency bitmap handle
    // hDC is background image handle
    AlphaBlend(hDC, 0, 0, 188, 69, hBmpDC, 0, 0, 188, 69, bf); 

沒有留言:

張貼留言