fix a bad refactor I did, fixes #1962

This commit is contained in:
adelikat 2020-05-01 18:15:48 -05:00
parent 9b19da24a0
commit 80273b9e28
1 changed files with 23 additions and 5 deletions

View File

@ -147,6 +147,21 @@ namespace BizHawk.Client.EmuHawk
}
}
private int ClampToByte(int val)
{
if (val < 0)
{
return 0;
}
if (val > 255)
{
return 255;
}
return val;
}
/// <summary>
/// Execute a second pass through the bitmap
/// </summary>
@ -168,9 +183,11 @@ namespace BizHawk.Client.EmuHawk
// Define the source data pointers. The source row is a byte to
// keep addition of the stride value easier (as this is in bytes)
byte* pSourceRow = (byte*)sourceData.Scan0.ToPointer();
int* pSourcePixel = (int*)pSourceRow;
// Now define the destination data pointers
byte* pDestinationRow = (byte*)outputData.Scan0.ToPointer();
byte* pDestinationPixel = pDestinationRow;
int[] errorThisRowR = new int[width + 1];
int[] errorThisRowG = new int[width + 1];
@ -184,8 +201,6 @@ namespace BizHawk.Client.EmuHawk
int ptrInc;
int* pSourcePixel;
byte* pDestinationPixel;
if ((row & 1) == 0)
{
pSourcePixel = (int*)pSourceRow;
@ -205,11 +220,14 @@ namespace BizHawk.Client.EmuHawk
// Quantize the pixel
int srcPixel = *pSourcePixel;
int srcR = srcPixel & 0xFF; //not
int srcG = (srcPixel >> 8) & 0xFF; //a
int srcB = (srcPixel >> 16) & 0xFF; //mistake
int srcA = (srcPixel >> 24) & 0xFF;
int targetB = 0;
int targetG = 0;
int targetR = 0;
int targetB = ClampToByte(srcB);
int targetG = ClampToByte(srcG);
int targetR = ClampToByte(srcR);
int targetA = srcA;
int target = (targetA << 24) | (targetB << 16) | (targetG << 8) | targetR;