From 9349ddf6045ca4d8e5df2744d4e0227dfb725a87 Mon Sep 17 00:00:00 2001 From: Kulikova Svetlana Date: Wed, 26 Apr 2023 18:50:15 +0300 Subject: [PATCH] Fix bug 62304 --- Fb2File/Fb2File.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Fb2File/Fb2File.cpp b/Fb2File/Fb2File.cpp index 3c83685c97..8673527ab1 100644 --- a/Fb2File/Fb2File.cpp +++ b/Fb2File/Fb2File.cpp @@ -293,7 +293,10 @@ public: { std::wstring sText = m_oLightReader.GetText(); if (sText.length() > 1) + { sImageName = sText.substr(1); + break; + } } } m_oLightReader.MoveToElement(); @@ -1053,12 +1056,15 @@ public: // Читает binary void getImage(const std::wstring& sImageId, const std::wstring& sMediaDirectory, NSStringUtils::CStringBuilder& oRels) { - std::wstring sId; + std::wstring sId, sType = L".png"; while (m_oLightReader.MoveToNextAttribute()) { + std::wstring sName = m_oLightReader.GetName(); // Читает id - if (m_oLightReader.GetName() == L"id") + if (sName == L"id") sId = m_oLightReader.GetText(); + else if (sName == L"content-type") + sType = m_oLightReader.GetText().find(L"jpeg") == std::wstring::npos ? L".png" : L".jpeg"; } m_oLightReader.MoveToElement(); if (sId.empty() || m_oLightReader.IsEmptyNode()) @@ -1066,7 +1072,8 @@ public: // Пишет картинку в файл NSFile::CFileBinary oImageWriter; - if (oImageWriter.CreateFileW(sMediaDirectory + L'/' + sId + (sId.find(L'.') == std::wstring::npos ? L".png" : L""))) + std::wstring sImagePath = sMediaDirectory + L"/image" + sImageId + sType; + if (oImageWriter.CreateFileW(sImagePath)) { std::string sBase64 = contentA(); int nSrcLen = (int)sBase64.length(); @@ -1079,7 +1086,7 @@ public: // Получаем размеры картинки CBgraFrame oBgraFrame; - oBgraFrame.OpenFile(sMediaDirectory + L'/' + sId); + oBgraFrame.OpenFile(sImagePath); int nHy = oBgraFrame.get_Height(); int nWx = oBgraFrame.get_Width(); if (nWx > nHy) @@ -1113,7 +1120,7 @@ public: oRels += L""; } }