Home > Software engineering >  Why the CImage: : Save Save file is 0 bytes empty file
Why the CImage: : Save Save file is 0 bytes empty file

Time:09-22

A drawing program, experimental read from BMP CImage, revised and save back,
 
The class CMFCApplication7Doc: public CDocument
{
//... Slightly
Public:
CImage m_image;
//... Slightly
};

//CMFCApplication7Doc serialization

Void CMFCApplication7Doc: : Serialize (CArchive& Ar)
{
If (ar) IsStoring ())
{
//TODO: add code stored in the
M_image. Save (ar. M_strFileName);
//also tried written m_image. Save (ar) m_strFileName, Gdiplus: : ImageFormatBMP);
}
The else
{
//TODO: add the load code
M_image. Load (ar. M_strFileName);
}
}

No change the rest of the doc,
After the operation can be correctly read and display in the view from the BMP, modified
But save the form file is always 0 bytes empty file, whether directly or save,

Set a breakpoint at the save track,
Ar. M_strFileName has a value of L "C: \ \ Users \ \ soft666 \ \ Desktop \ \ C3 BMP"
M_image the attributes of the
M_nWidth 1152
M_nHeight 648

Visible path there is no problem, save m_image nor empty Cimage

In the rc IDR_MAINFRAME also set the value of the
MFCApplication7 \ n \ nMFCApplication7 \ n.b mp \ n.b mp \ nMFCApplication7 Document \ nMFCApplication7 Document
Should match,

So what is the problem?

CodePudding user response:

Save the return value is e_fail, is on track in win32error (7)
Permissions seems to be the problem? But with administrator privileges to run not to solve the problem

CodePudding user response:

Ar. M_strFileName didn't shut down
Change of the save

CodePudding user response:

Thanks to the upstairs, have been solved
  • Related