I have this error in atlimage.h line 1568 while trying to save picture. In release mode everything is "fine" but no new file appears. Here is the code:

    CClientDC dc(this); 
    CDC       dcMem;
    CBitmap   m_bmpBack;

    hBmp = LoadImage(NULL,name,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);   
    GetObject ( hBmp, sizeof(bm), &bm );    

    hbmpOld = (HBITMAP)dcMem.SelectObject(m_bmpBack);

    //hToSave = (HBITMAP)hBmp;
    //hToSave = (HBITMAP)m_bmpBack;
    //hToSave = (HBITMAP)dcMem.SelectObject(m_bmpBack);
    hToSave = (HBITMAP)dcMem.GetCurrentBitmap(); //I tried each of them, all the same result(

    dc.StretchBlt(rc.left, rc.top, rc.right, rc.bottom,&dcMem, 0, 0, (int)bm.bmWidth, (int)bm.bmHeight, SRCCOPY); 

    CImage myImage;
    if (hToSave!=NULL)
        name = L"d:/backgrnd.bmp";

What I have to add or remove to make this work?

Recommended Answers

Is the hBmp NULL?

Jump to Post

All 2 Replies

Is the hBmp NULL?

commented: right direction clue +0

This code was in OnPaint as I remember, and it seems to me, yes, I've added a kind of hBmp = null and m_bmpBack.DeleteObject(); and even myImage.Destroy(); at the beginning and everything works fine now.

But thanks!) your question could give me some clue to the solvation of my problems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.