diff --git a/src/WinIMerge/WinIMerge.cpp b/src/WinIMerge/WinIMerge.cpp index 6f36577..646f46b 100644 --- a/src/WinIMerge/WinIMerge.cpp +++ b/src/WinIMerge/WinIMerge.cpp @@ -481,7 +481,18 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; } case ID_FILE_SAVE: - m_pImgMergeWindow->SaveImages(); + for (int pane = 0; pane < m_pImgMergeWindow->GetPaneCount(); ++pane) + { + if (m_pImgMergeWindow->IsSaveSupported(pane)) + { + if (!m_pImgMergeWindow->SaveImage(pane)) + { + SaveImageAs(hWnd, pane); + } + } + else + SaveImageAs(hWnd, pane); + } break; case ID_FILE_SAVE_LEFT_AS: SaveImageAs(hWnd, 0); diff --git a/src/WinIMergeLib/ImgMergeBuffer.hpp b/src/WinIMergeLib/ImgMergeBuffer.hpp index 4210bbd..0c62e42 100644 --- a/src/WinIMergeLib/ImgMergeBuffer.hpp +++ b/src/WinIMergeLib/ImgMergeBuffer.hpp @@ -388,6 +388,11 @@ class CImgMergeBuffer : public CImgDiffBuffer m_undoRecords.set_savepoint(pane, pos); } + bool IsSaveSupported(int pane) const + { + return !m_imgConverter[pane].isValid() && m_imgOrig[pane].isSaveSupported(); + } + bool SaveImage(int pane) { if (pane < 0 || pane >= m_nImages) diff --git a/src/WinIMergeLib/ImgMergeWindow.hpp b/src/WinIMergeLib/ImgMergeWindow.hpp index 65f31b8..42caa34 100644 --- a/src/WinIMergeLib/ImgMergeWindow.hpp +++ b/src/WinIMergeLib/ImgMergeWindow.hpp @@ -1174,6 +1174,11 @@ class CImgMergeWindow : public IImgMergeWindow m_buffer.SetSavePoint(pane, pos); } + bool IsSaveSupported(int pane) const override + { + return m_buffer.IsSaveSupported(pane); + } + private: ATOM MyRegisterClass(HINSTANCE hInstance) diff --git a/src/WinIMergeLib/WinIMergeLib.h b/src/WinIMergeLib/WinIMergeLib.h index dad828c..2ad91d3 100644 --- a/src/WinIMergeLib/WinIMergeLib.h +++ b/src/WinIMergeLib/WinIMergeLib.h @@ -182,6 +182,7 @@ struct IImgMergeWindow virtual void SetVerticalFlip(int pane, bool flip) = 0; virtual DIFF_ALGORITHM GetDiffAlgorithm() const = 0; virtual void SetDiffAlgorithm(DIFF_ALGORITHM diffAlgorithm) = 0; + virtual bool IsSaveSupported(int pane) const = 0; }; struct IImgToolWindow diff --git a/src/WinIMergeLib/image.hpp b/src/WinIMergeLib/image.hpp index a3074fc..d2c1a30 100644 --- a/src/WinIMergeLib/image.hpp +++ b/src/WinIMergeLib/image.hpp @@ -293,6 +293,7 @@ class Image return image_.convertTo8Bits() && image_.convertTo32Bits(); } bool load(const std::wstring& filename) { return !!image_.loadU(filename.c_str()); } + bool isSaveSupported() const { return FreeImage_FIFSupportsWriting(image_.getFIF()); } bool save(const std::wstring& filename) { #ifdef _WIN32