From c841a7249c519ec3003eede83bbfe58cf5a5499a Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Fri, 25 Dec 2020 11:42:02 +0300 Subject: [PATCH] fix type of image --- DesktopEditor/doctrenderer/graphics.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/DesktopEditor/doctrenderer/graphics.cpp b/DesktopEditor/doctrenderer/graphics.cpp index 526063e9ed..10d746977a 100644 --- a/DesktopEditor/doctrenderer/graphics.cpp +++ b/DesktopEditor/doctrenderer/graphics.cpp @@ -1022,7 +1022,7 @@ std::string CGraphics::toDataURL(std::wstring type) { size_t nSl = type.find(L'/'); if(nSl != std::wstring::npos) - type.erase(nSl); + type.erase(0, nSl + 1); std::wstring sPath = m_sApplicationImagesDirectory + L"/img." + type; m_oFrame.SaveFile(sPath, _CXIMAGE_FORMAT_PNG); @@ -1034,12 +1034,15 @@ std::string CGraphics::toDataURL(std::wstring type) DWORD dwReaded; oReader.ReadFile(pFileContent, dwFileSize, dwReaded); oReader.CloseFile(); - NSFile::CFileBinary::Remove(sPath); + //NSFile::CFileBinary::Remove(sPath); int nEncodeLen = NSBase64::Base64EncodeGetRequiredLength(dwFileSize); BYTE* pImageData = new BYTE[nEncodeLen]; if(TRUE == NSBase64::Base64Encode(pFileContent, dwFileSize, pImageData, &nEncodeLen)) - return std::string((char*)pImageData, nEncodeLen); + { + std::string sRes = std::string((char*)pImageData, nEncodeLen); + return sRes; + } } return ""; }