Skip to content

Commit

Permalink
Fixed bug in WindowBlendImage mode 4 (dissolve)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Feb 17, 2010
1 parent bcb73dc commit a3b5ac6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
32 changes: 29 additions & 3 deletions miniwindow.cpp
Expand Up @@ -2089,9 +2089,35 @@ long CMiniWindow::BlendImage(LPCTSTR ImageId,
case 2: Blend_It (Blend_Average); break;
case 3: Blend_It (Blend_Interpolate); break;

case 4: // dissolve - randomly choose pixels based on opacity
for (i = 0; i < count; i++)
pB [i] = (genrand () < Opacity) ? pA [i] : pB [i];
case 4: // dissolve - randomly choose pixels based on opacity
{

for (row = 0; row < iHeight; row++)
{
long base = row * perline;
unsigned char rA, gA, bA, rB, gB, bB;
for (i = 0; i < perline - 2; )
{
double rnd = genrand ();
bA = pA [base + i];
gA = pA [base + i + 1];
rA = pA [base + i + 2];

bB = pB [base + i];
gB = pB [base + i + 1];
rB = pB [base + i + 2];

pB [base + i] = (rnd < Opacity) ? rA : rB;;
i++;
pB [base + i] = (rnd < Opacity) ? gA : gB;
i++;
pB [base + i] = (rnd < Opacity) ? bA : bB;
i++;

}
} // end for each row

}
break;

// darkening modes
Expand Down
10 changes: 7 additions & 3 deletions scripting/methods.cpp
Expand Up @@ -13775,9 +13775,13 @@ long r, g, b;
case 3: Blend_It (Blend_Interpolate); break;

case 4: // dissolve - randomly choose pixels based on opacity
r = (genrand () < Opacity) ? rA : rB;
g = (genrand () < Opacity) ? gA : gB;
b = (genrand () < Opacity) ? bA : bB;
{
double rnd = genrand ();

r = (rnd < Opacity) ? rA : rB;
g = (rnd < Opacity) ? gA : gB;
b = (rnd < Opacity) ? bA : bB;
}
break;


Expand Down

0 comments on commit a3b5ac6

Please sign in to comment.