我正在编写一个程序,该程序使用掩码(覆盖图像)从 png 图像中删除覆盖
拥有图像 1 和 2 我想获得图像 3。
我尝试过使用 lockbits 并尝试了很多事情,但我认为我无法正确计算
rgbValues 是覆盖的字节数组,rgbValues2 是给定图像的字节数组。
for (int counter = 0; counter < rgbValues.Length; counter ++)
{
int x = (counter / 4) * 4;
if (rgbValues[x + 3] != 0)
{
if (rgbValues[x + 3] == rgbValues2[x + 3])
{
rgbValues2[counter] = 0;
}
else
{
float a1 = (float)rgbValues[counter];
float a2 = (float)rgbValues2[counter] ;
float b1 = (float)rgbValues[x + 3];
float b2 = (float)rgbValues2[x + 3];
rgbValues2[counter] = (byte)(2 * a2- a1);
}
}
}