110,534
社区成员
发帖
与我相关
我的任务
分享
Bitmap src= new Bitmap(......原图路径);
Bitmap bit = new Bitmap(src.Width, src.Height);
Graphics g = Graphics.FromImage(bit);
g.DrawImage(src, new Rectangle(0, 0, BitmapInfo.Width, BitmapInfo.Height), new Rectangle(0, 0, BitmapInfo.Width, BitmapInfo.Height), GraphicsUnit.Pixel);
private unsafe int GetMax(Bitmap bit)
{
BitmapData bitdata = bit.LockBits(new Rectangle(0, 0, bit.Width, bit.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
byte* bitByte = (byte*)bitdata.Scan0;
int h = bit.Height;
int w = bit.Width;
int max = 0;
for (int j = 0; j < h; ++j)
{
for (int i = 0; i < w; ++i)
{
if (bitByte[0] > max)
{ max = bitByte[0]; }
bitByte += 4;
}
}
bit.UnlockBits(bitdata);
return max;
}