Load a CBitmap dynamically

前端 未结 8 1778
情深已故
情深已故 2021-02-06 02:59

I have a Bitmap image that i want to load dynamically. But I am unable to load it.

CBitmap bmp;

bmp.LoadBitmap(\"c:\\\\aeimg\");

it does not

相关标签:
8条回答
  • 2021-02-06 03:45

    CImage doesn't work with png last time I tried / checked. Have a look at CxImage - http://www.codeproject.com/KB/graphics/cximage.aspx .

    0 讨论(0)
  • 2021-02-06 03:55

    When using the solutions mentioned to date, with a member variable of CBitmap I kept getting memory leaking every time I loaded the CImage onto the CBitmap. I solved this with the following code:

    CString _fileName(/*Path to image*/);
    CImage _image;          
    HRESULT hr = _image.Load(_fileName);
    if (SUCCEEDED(hr)) {
        if (m_Display.m_bmpImage.DeleteObject())
            m_Display.m_bmpImage.Detach();              
        m_bmpImage.Attach(_image->Detach());
    }
    
    0 讨论(0)
提交回复
热议问题