本文介绍了这段代码是对的吗?因为我有退出代码1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨;



我问我的代码是不是?因为我在调试器中获得退出代码1,程序很好并且工作正常但很少崩溃,代码是从图片控件获取图片并将图像保存到文件,这是我的代码片段;

hi;

i ask about my code is it right? because i get exit code 1 in debugger ,the program is fine and work good but it crashs rarely, the code is to get picture from picture control and save the image to file, here is a piece of my code;

#include <atlimage.h>

#include <Gdiplusimaging.h>

//take snapshot of pic

CDC dc;


	CRect rect;
CWnd *wnd = GetDlgItem(IDC_SHOW_PICTURE_STATUS2);
wnd->GetWindowRect(&rect);


         HDC hdc = ::GetDC(wnd->m_hWnd);
         dc.Attach(hdc);


     CDC memDC;

     memDC.CreateCompatibleDC(&dc);

     CBitmap bm;
     CRect r;


         wnd->GetClientRect(&r);


     CString s;
     wnd->GetWindowText(s);

     CSize sz(r.Width(), r.Height());

     bm.CreateCompatibleBitmap(&dc, sz.cx, sz.cy);

     CBitmap * oldbm = memDC.SelectObject(&bm);

     memDC.BitBlt(0, 0, sz.cx, sz.cy, &dc, 0, 0, SRCCOPY);



	 CImage image;

        image.Attach(bm);

        image.Save(bmp_file, Gdiplus::ImageFormatBMP);




     memDC.SelectObject(oldbm);
     bm.Detach();

推荐答案


这篇关于这段代码是对的吗?因为我有退出代码1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-29 05:09
查看更多