Skip to content

Commit

Permalink
Revert "Fix issue WinMerge/winmerge#2370: Image Comparison : In Alpha…
Browse files Browse the repository at this point in the history
… Animation, dialogs hang winmerge"

This reverts commit a305270.
  • Loading branch information
sdottaka committed Jul 7, 2024
1 parent a305270 commit 41babf1
Showing 1 changed file with 28 additions and 90 deletions.
118 changes: 28 additions & 90 deletions src/WinIMergeLib/ImgDiffBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ class CImgDiffBuffer
, m_overlayAlpha(0.3)
, m_wipeMode(WIPE_NONE)
, m_wipePosition(0)
, m_wipePosition_old(INT_MAX)
, m_diffBlockSize(8)
, m_selDiffColor(Image::Rgb(0xff, 0x40, 0x40))
, m_selDiffDeletedColor(Image::Rgb(0xf0, 0xc0, 0xc0))
Expand Down Expand Up @@ -778,7 +777,7 @@ class CImgDiffBuffer
if (m_wipePosition == pos)
return;
m_wipePosition = pos;
WipeEffect();
RefreshImages();
}

void SetWipeModePosition(WIPE_MODE wipeMode, int pos)
Expand Down Expand Up @@ -1135,6 +1134,10 @@ class CImgDiffBuffer
(this->*func)(1, 2);
}
}
if (m_wipeMode != WIPE_NONE)
{
WipeEffect();
}
if (m_showDifferences)
{
bool showDiff = true;
Expand All @@ -1154,7 +1157,6 @@ class CImgDiffBuffer
MarkDiff(i, m_diff);
}
}
m_wipePosition_old = INT_MAX;
}

bool OpenImages(int nImages, const wchar_t * const filename[3])
Expand Down Expand Up @@ -1876,112 +1878,49 @@ class CImgDiffBuffer
const unsigned w = m_imgDiff[0].width();
const unsigned h = m_imgDiff[0].height();

if (m_wipePosition <= 0)
m_wipePosition = 0;

if (m_wipeMode == WIPE_VERTICAL)
{
if (m_wipePosition >= h)
m_wipePosition = h;
if (m_wipePosition_old == INT_MAX)
m_wipePosition_old = h;
auto tmp = new unsigned char[w * 4];
if (m_wipePosition <= m_wipePosition_old)
{
for (unsigned y = m_wipePosition; y < m_wipePosition_old; ++y)
{
for (int pane = 0; pane < m_nImages - 1; ++pane)
{
unsigned char* scanline = m_imgDiff[pane].scanLine(y);
unsigned char* scanline2 = m_imgDiff[pane + 1].scanLine(y);
memcpy(tmp, scanline, w * 4);
memcpy(scanline, scanline2, w * 4);
memcpy(scanline2, tmp, w * 4);
}
}
}
else
for (unsigned y = m_wipePosition; y < h; ++y)
{
for (unsigned y = m_wipePosition_old; y < m_wipePosition; ++y)
for (int pane = 0; pane < m_nImages - 1; ++pane)
{
for (int pane = m_nImages - 1; pane > 0; --pane)
{
unsigned char* scanline = m_imgDiff[pane].scanLine(y);
unsigned char* scanline2 = m_imgDiff[pane - 1].scanLine(y);
memcpy(tmp, scanline, w * 4);
memcpy(scanline, scanline2, w * 4);
memcpy(scanline2, tmp, w * 4);
}
unsigned char *scanline = m_imgDiff[pane].scanLine(y);
unsigned char *scanline2 = m_imgDiff[pane + 1].scanLine(y);
memcpy(tmp, scanline, w * 4);
memcpy(scanline, scanline2, w * 4);
memcpy(scanline2, tmp, w * 4);
}
}

delete[] tmp;
}
else if (m_wipeMode = WIPE_HORIZONTAL)
{
if (m_wipePosition >= w)
m_wipePosition = w;
if (m_wipePosition_old == INT_MAX)
m_wipePosition_old = w;
for (unsigned y = 0; y < h; ++y)
{
for (int pane = 0; pane < m_nImages - 1; ++pane)
{
unsigned char* scanline;
unsigned char* scanline2;
if (m_wipePosition <= m_wipePosition_old)
{
scanline = m_imgDiff[pane].scanLine(y);
scanline2 = m_imgDiff[pane + 1].scanLine(y);
}
else
{
scanline = m_imgDiff[m_nImages - 2 - pane].scanLine(y);
scanline2 = m_imgDiff[m_nImages - 1 - pane].scanLine(y);
}

if (m_wipePosition <= m_wipePosition_old)
unsigned char *scanline = m_imgDiff[pane].scanLine(y);
unsigned char *scanline2 = m_imgDiff[pane + 1].scanLine(y);
for (unsigned x = m_wipePosition; x < w; ++x)
{
for (unsigned x = m_wipePosition; x < m_wipePosition_old; ++x)
{
unsigned char tmp[4];
tmp[0] = scanline[x * 4 + 0];
tmp[1] = scanline[x * 4 + 1];
tmp[2] = scanline[x * 4 + 2];
tmp[3] = scanline[x * 4 + 3];
scanline[x * 4 + 0] = scanline2[x * 4 + 0];
scanline[x * 4 + 1] = scanline2[x * 4 + 1];
scanline[x * 4 + 2] = scanline2[x * 4 + 2];
scanline[x * 4 + 3] = scanline2[x * 4 + 3];
scanline2[x * 4 + 0] = tmp[0];
scanline2[x * 4 + 1] = tmp[1];
scanline2[x * 4 + 2] = tmp[2];
scanline2[x * 4 + 3] = tmp[3];
}
}
else
{
for (unsigned x = m_wipePosition_old; x < m_wipePosition; ++x)
{
unsigned char tmp[4];
tmp[0] = scanline[x * 4 + 0];
tmp[1] = scanline[x * 4 + 1];
tmp[2] = scanline[x * 4 + 2];
tmp[3] = scanline[x * 4 + 3];
scanline[x * 4 + 0] = scanline2[x * 4 + 0];
scanline[x * 4 + 1] = scanline2[x * 4 + 1];
scanline[x * 4 + 2] = scanline2[x * 4 + 2];
scanline[x * 4 + 3] = scanline2[x * 4 + 3];
scanline2[x * 4 + 0] = tmp[0];
scanline2[x * 4 + 1] = tmp[1];
scanline2[x * 4 + 2] = tmp[2];
scanline2[x * 4 + 3] = tmp[3];
}
unsigned char tmp[4];
tmp[0] = scanline[x * 4 + 0];
tmp[1] = scanline[x * 4 + 1];
tmp[2] = scanline[x * 4 + 2];
tmp[3] = scanline[x * 4 + 3];
scanline[x * 4 + 0] = scanline2[x * 4 + 0];
scanline[x * 4 + 1] = scanline2[x * 4 + 1];
scanline[x * 4 + 2] = scanline2[x * 4 + 2];
scanline[x * 4 + 3] = scanline2[x * 4 + 3];
scanline2[x * 4 + 0] = tmp[0];
scanline2[x * 4 + 1] = tmp[1];
scanline2[x * 4 + 2] = tmp[2];
scanline2[x * 4 + 3] = tmp[3];
}
}
}
}
m_wipePosition_old = m_wipePosition;
}

void CopyPreprocessedImageToDiffImage(int dst)
Expand Down Expand Up @@ -2318,7 +2257,6 @@ class CImgDiffBuffer
double m_overlayAlpha;
WIPE_MODE m_wipeMode;
int m_wipePosition;
int m_wipePosition_old;
unsigned m_diffBlockSize;
Image::Color m_selDiffColor;
Image::Color m_selDiffDeletedColor;
Expand Down

0 comments on commit 41babf1

Please sign in to comment.