bitmapdata dataout = bitmap.lockbits(new rectangle(0, 0, width, height), imagelockmode.readwrite, pixelformat.format24bpprgb);
int offset = dataout.stride - dataout.width * 3;
try
{
unsafe
{
byte* pout = (byte*)(dataout.scan0.topointer());
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
tempb = pout[0];
tempg = pout[1];
tempr = pout[2];
double data=0.31 * tempr + 0.59 * tempg + 0.11 * tempb;
if (data > 255)
sporigindata[y][x] = 255;
else
if (data < 0)
sporigindata[y][x] = 0;
else
sporigindata[y][x] = (short)data;
pout += 3;
}
pout += offset;
}
bitmap.unlockbits(dataout);
}
}
catch
{
}
return sporigindata;
}
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论