CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2007
    Posts
    4

    Unhappy Bitmap TransparentBlt problems

    ...
    class Bitmap
    {
    protected:
    // Member Variables
    HBITMAP m_hBitmap;
    int m_iWidth, m_iHeight;

    // Helper Methods
    void Free();

    public:
    // Constructor(s)/Destructor
    Bitmap();
    Bitmap(HDC hDC, LPTSTR szFileName);
    Bitmap(HDC hDC, UINT uiResID, HINSTANCE hInstance);
    Bitmap(HDC hDC, int iWidth, int iHeight, COLORREF crColor = RGB(0, 0, 0));
    virtual ~Bitmap();

    // General Methods
    BOOL Create(HDC hDC, LPTSTR szFileName);
    BOOL Create(HDC hDC, UINT uiResID, HINSTANCE hInstance);
    BOOL Create(HDC hDC, int iWidth, int iHeight, COLORREF crColor);
    void Draw(HDC hDC, int x, int y, BOOL bTrans = FALSE,
    COLORREF crTransColor = RGB(255, 0, 255));
    int GetWidth() { return m_iWidth; };
    int GetHeight() { return m_iHeight; };
    };

    ...

    void Bitmap:raw(HDC hDC, int x, int y, BOOL bTrans, COLORREF crTransColor)
    {
    if (m_hBitmap != NULL)
    {
    // Create a memory device context for the bitmap
    HDC hMemDC = CreateCompatibleDC(hDC);

    // Select the bitmap into the device context
    HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, m_hBitmap);

    // Draw the bitmap to the destination device context
    if (bTrans)
    TransparentBlt(hDC, x, y, GetWidth(), GetHeight(), hMemDC, 0, 0, GetWidth(), GetHeight(), crTransColor);

    else
    BitBlt(hDC, x, y, GetWidth(), GetHeight(), hMemDC, 0, 0, SRCCOPY);

    // Restore and delete the memory device context
    SelectObject(hMemDC, hOldBitmap);
    DeleteDC(hMemDC);
    }
    }

    ...

    _pMB_Up->Draw(hDC, 494, 524);
    _pMB_Right->Draw(hDC, 548, 578);
    _pMB_Left->Draw(hDC, 422, 578);

    ...

    1>Bitmap.obj : error LNK2019: unresolved external symbol __imp__TransparentBlt@44 referenced in function "public: void __thiscall Bitmap:raw(struct HDC__ *,int,int,int,unsigned long)" (?Draw@Bitmap@@QAEXPAUHDC__@@HHHK@Z)

    ///////////////////////////////////////////////////

    HELP!

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Bitmap TransparentBlt problems

    From MSDN article(""):
    Requirements
    ...
    Header
    WinGdi.h (include Windows.h)
    Library
    Msimg32.lib
    DLL
    Msimg32.dll
    So try to add Msimg32.lib in the list of objects/libraries modules...
    Victor Nijegorodov

  3. #3
    Join Date
    Sep 2007
    Posts
    4

    Re: Bitmap TransparentBlt problems

    #pragma comment(lib, "Msimg32.lib")
    Thank you =D

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured