=========MFC++版本
private: static Boolean __gc* BitmapHasAlpha(BitmapData __gc* bmpData)
{
if ((bmpData->PixelFormat != PixelFormat::Format32bppArgb) && (bmpData->PixelFormat != PixelFormat::Format32bppRgb))
{
return false;
}
for (Int32 __gc* i = 0; (i < bmpData->Height); i++)
{
Int32 __gc* num2 = (i * bmpData->Stride);
for (Int32 __gc* j = 3; (j < (bmpData->Width * 4)); j += 4)
{
Byte __gc** numPtr = *static_cast<__box Byte __gc***>(((bmpData->Scan0->ToPointer() + num2) + j));
if (numPtr[0] != 0)
{
return true;
}
}
}
return false;
}
=========C#版本
private static unsafe bool BitmapHasAlpha(BitmapData bmpData)
{
if ((bmpData.PixelFormat != PixelFormat.Format32bppArgb) && (bmpData.PixelFormat != PixelFormat.Format32bppRgb))
{
return false;
}
for (int i = 0; i < bmpData.Height; i++)
{
int num2 = i * bmpData.Stride;
for (int j = 3; j < (bmpData.Width * 4); j += 4)
{
byte* numPtr = ((byte*)bmpData.Scan0.ToPointer()) + num2 + j;
if (numPtr[0] != 0)
{
return true;
}
}
}
return false;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)