zoukankan      html  css  js  c++  java
  • 如何在VC中显示透明背景位图

    简单的调用系统API。

    Windows NT/2000/XP: Included in Windows 2000 and later.
    Windows 95/98/Me: Included in Windows 98 and later.
    Header: Declared in Wingdi.h; include Windows.h.
    Library: Use Msimg32.lib.

    void CTransparentBltTestDlg::OnPaint()
    {
    CPaintDC dc(this); // device context for painting

    CDialog::OnPaint();
    COLORREF crMask = RGB(0x00,0x00,0xff); // Mask color of bitmap
    BITMAP bm;
    m_bmp.GetBitmap(&bm);
    int nWidth = bm.bmWidth;
    int nHeight = bm.bmHeight;
    CDC ImageDC;
    ImageDC.CreateCompatibleDC(&dc);
    CBitmap *pOldImageBMP = ImageDC.SelectObject(&m_bmp);
    ::TransparentBlt(dc.m_hDC,50,40,nWidth,nHeight,ImageDC.m_hDC,0,0,nWidth,nHeight,crMask);
    ImageDC.SelectObject(pOldImageBMP);
    }
    }
    TransparentBlt
    The TransparentBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.

    Parameters
    hdcDest
    [in] Handle to the destination device context.
    nXOriginDest
    [in] Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
    nYOriginDest
    [in] Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
    nWidthDest
    [in] Specifies the width, in logical units, of the destination rectangle.
    hHeightDest
    [in] Handle to the height, in logical units, of the destination rectangle.
    hdcSrc
    [in] Handle to the source device context.
    nXOriginSrc
    [in] Specifies the x-coordinate, in logical units, of the source rectangle.
    nYOriginSrc
    [in] Specifies the y-coordinate, in logical units, of the source rectangle.
    nWidthSrc
    [in] Specifies the width, in logical units, of the source rectangle.
    nHeightSrc
    [in] Specifies the height, in logical units, of the source rectangle.
    crTransparent
    [in] The RGB color in the source bitmap to treat as transparent.
    Return Values
    If the function succeeds, the return value is TRUE.
    If the function fails, the return value is FALSE.
    Windows NT/2000/XP: To get extended error information, call GetLastError .

    http://blog.csdn.net/harbinzju/article/details/5844798

  • 相关阅读:
    Windows下安装MongoDB
    介绍了MongoDB在32位Windows7下的安装以及一些简单应用
    简单的实例来理解WCF 数据服务
    对缓存的思考——提高命中率
    如何在安装过程中部署DevExpress控件
    [WCF REST] 解决资源并发修改的一个有效的手段:条件更新(Conditional Update)
    MEF实现IoC
    Lucene索引分析工具Luke.Net 0.5升级版 (兼容Lucene.Net 2.9.4.1)
    Mongodb在windows下面作为服务启动 出现“服务没有响应控制功能”
    写自己的ASP.NET MVC框架
  • 原文地址:https://www.cnblogs.com/findumars/p/5460136.html
Copyright © 2011-2022 走看看