C# 的高效方法取得图片的像素区数据。
// Lock the bitmap's bits. Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);BitmapData bmpData = image.LockBits(rect, ImageLockMode.ReadWrite, image.PixelFormat);// Get the address of the first line.IntPtr ptr = bmpData.Scan0;// Declare an array to hold the bytes of the bitmap.int bytes = Math.Abs(bmpData.Stride) * image.Height;byte[] rgbValues = new byte[bytes];// Copy the RGB values into the array.Marshal.Copy(ptr, rgbValues, 0, bytes);// Unlock the bits.image.UnlockBits(bmpData);return rgbValues;
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。