我正在尝试确定一个1BPP索引TIFF图像是使用白色像素还是黑色像素。为了检查我的代码是否正确,我让应用程序将处理后的相同图像绘制到新图像上。这时我注意到了一些问题,我一直在努力解决它。
我很确定这与我的按位检查有关!
原始图像
处理后的图像
测试项目可从http://www.unclickable.net/code/tiffTest.zip下载
unsafe { //flipStartPoint
我很确定这与我的按位检查有关!
原始图像
![origninal image A](https://istack.dev59.com/JrCc1.webp)
![enter image description here](https://istack.dev59.com/SHtLy.webp)
unsafe { //flipStartPoint
int y;
for (y = 0; y < tiffSource.Height; y++)
{
var Column = (byte*)tiffSource.GetScanlinePointer(y);
int x;
for (x = 0; x < (tiffSource.Width / 8); x++)
{
int xm = x * 8;
byte b = Column[xm];
if (b > 0)
{
for (int Z = 0; Z < 8; Z++)
{
if (((b & (128 >> Z)) != 0))
{
if (lowisWhite)
{
image1.SetPixel((xm + Z), y, Color.FromArgb(0, 255, 255,255));
}
}
else
{
if (!lowisWhite)
{
image1.SetPixel((xm + Z), y, Color.FromArgb(0, 255,255, 255));
}
}
}
}
else
{
if (!lowisWhite)
{
for (int Z = 0; Z < 8; Z++)
{
image1.SetPixel((xm + Z), y, Color.FromArgb(0, 255, 255, 255));
}
}
}
}
}
}