how to reduce memory usage while loading background image in MFC Application?

cpp India
  • 13 years ago
    In MFC application (Dialog based or Cform view), if i load bitmap image in the background, its taking more memory.. here is my coding..

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

    HBITMAP m_Bmap;
    CRect rect;
    HDC memdc;

    CString m_ifilename1;

    m_ifilename1 = "C:\\test.bmp";

    GetClientRect(&rect);

    m_Bmap=(HBITMAP)::LoadImage(NULL,m_ifilename1,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
    memdc=::CreateCompatibleDC(dc.m_hDC);
    ::SelectObject(memdc,m_Bmap);

    BitBlt(dc.m_hDC,0,0,rect.right,rect.bottom,memdc,0,0,SRCCOPY);
    DeleteObject(m_Bmap);
    DeleteObject(memdc);
    }

    is it correct ? and also let me know is there any memory leakage?
    is it possible to load jpeg image in MFC dialog? (to avoid more memory usage)

    Thanks in Advance...





    Abdul Khathar A



































Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only 3 numbers of interest to a computer scientist: 1, 0 and infinity”