Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/WinIMergeLib/ImgMergeBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ class CImgMergeBuffer : public CImgDiffBuffer
m_bRO[i] = false;
}

virtual ~CImgMergeBuffer()
{
}
virtual ~CImgMergeBuffer() = default;

bool NewImages(int nImages, int nPages, int width, int height)
{
Expand Down Expand Up @@ -320,6 +318,12 @@ class CImgMergeBuffer : public CImgDiffBuffer
{
if (pane < 0 || pane >= m_nImages || m_bRO[pane])
return false;
left = (std::max)(left, 0);
top = (std::max)(top, 0);
right = (std::min)(right, static_cast<int>(m_imgOrig32[pane].width()));
bottom = (std::min)(bottom, static_cast<int>(m_imgOrig32[pane].height()));
if (right <= left || bottom <= top)
return false;

Image *oldbitmap = new Image(m_imgOrig32[pane]);

Expand Down Expand Up @@ -471,8 +475,7 @@ class CImgMergeBuffer : public CImgDiffBuffer

virtual bool CloseImages() override
{
for (int i = 0; i < m_nImages; ++i)
m_undoRecords.clear();
m_undoRecords.clear();
return CImgDiffBuffer::CloseImages();
}

Expand All @@ -484,6 +487,14 @@ class CImgMergeBuffer : public CImgDiffBuffer
Image *oldbitmap = new Image(m_imgOrig32[pane]);
{
TemporaryTransformation tmp(*this);
int width = (std::max)(static_cast<int>(m_imgOrig32[pane].width()), x + static_cast<int>(image.width()));
int height = (std::max)(static_cast<int>(m_imgOrig32[pane].height()), y + static_cast<int>(image.height()));
if (width != static_cast<int>(m_imgOrig32[pane].width()) || height != static_cast<int>(m_imgOrig32[pane].height()))
{
Image tmpImage = m_imgOrig32[pane];
m_imgOrig32[pane].setSize(width, height);
PasteImageInternal(pane, 0, 0, tmpImage);
}
PasteImageInternal(pane, x, y, image);
}
Image *newbitmap = new Image(m_imgOrig32[pane]);
Expand Down
24 changes: 21 additions & 3 deletions src/WinIMergeLib/ImgMergeWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,17 @@ class CImgMergeWindow : public IImgMergeWindow

void SetCurrentPage(int pane, int page) override
{
CommitOverlappedImages();
m_buffer.SetCurrentPage(pane, page);
UpdateScrollBars();
Invalidate();
}

void SetCurrentPageAll(int page) override
{
CommitOverlappedImages();
m_buffer.SetCurrentPageAll(page);
UpdateScrollBars();
Invalidate();
}

Expand Down Expand Up @@ -650,18 +654,21 @@ class CImgMergeWindow : public IImgMergeWindow

void CopyDiff(int diffIndex, int srcPane, int dstPane) override
{
CommitOverlappedImages();
m_buffer.CopyDiff(diffIndex, srcPane, dstPane);
Invalidate();
}

void CopyDiffAll(int srcPane, int dstPane) override
{
CommitOverlappedImages();
m_buffer.CopyDiffAll(srcPane, dstPane);
Invalidate();
}

int CopyDiff3Way(int dstPane) override
{
CommitOverlappedImages();
int result = m_buffer.CopyDiff3Way(dstPane);
Invalidate();
return result;
Expand Down Expand Up @@ -759,6 +766,7 @@ class CImgMergeWindow : public IImgMergeWindow
int pane = GetActivePane();
if (pane < 0 || !m_imgWindow[pane].IsRectanlgeSelectionVisible())
return false;
CommitOverlappedImages();
Image image;
RECT rc = ConvertToRealRect(pane, m_imgWindow[pane].GetRectangleSelection(), false);
m_buffer.CopySubImage(pane, rc.left, rc.top, rc.right, rc.bottom, image);
Expand All @@ -778,6 +786,12 @@ class CImgMergeWindow : public IImgMergeWindow
return false;
RECT rc = ConvertToRealRect(pane, m_imgWindow[pane].GetRectangleSelection(), false);
Cancel();
rc.left = (std::max)(rc.left, 0L);
rc.top = (std::max)(rc.top, 0L);
rc.right = (std::min)(rc.right, static_cast<long>(m_buffer.GetImageWidth(pane)));
rc.bottom = (std::min)(rc.bottom, static_cast<long>(m_buffer.GetImageHeight(pane)));
if (rc.right <= rc.left || rc.bottom <= rc.top)
return false;
bool result = m_buffer.DeleteRectangle(pane, rc.left, rc.top, rc.right, rc.bottom);
if (result)
Invalidate();
Expand All @@ -794,9 +808,6 @@ class CImgMergeWindow : public IImgMergeWindow
fipImageEx image;
image.pasteFromClipboard();
image.convertTo32Bits();
int maxwidth = (std::max)(m_buffer.GetImageWidth(pane), static_cast<int>(image.getWidth()));
int maxheight = (std::max)(m_buffer.GetImageHeight(pane), static_cast<int>(image.getHeight()));
m_buffer.Resize(pane, maxwidth, maxheight);
imgWindow.SetOverlappedImage(image);
imgWindow.Invalidate();
return true;
Expand Down Expand Up @@ -835,6 +846,7 @@ class CImgMergeWindow : public IImgMergeWindow
m_imgWindow[pane].DeleteRectangleSelection();
m_imgWindow[pane].DeleteOverlappedImage();
}
UpdateScrollBars();
Invalidate();
return true;
}
Expand Down Expand Up @@ -1707,6 +1719,12 @@ class CImgMergeWindow : public IImgMergeWindow
Invalidate();
}

void CommitOverlappedImages()
{
for (int pane = 0; pane < m_nImages; ++pane)
PasteAndDeleteOverlappedImage(pane);
}

void PasteAndDeleteOverlappedImage(int pane)
{
PasteOverlappedImage(pane);
Expand Down
Loading