c#读取图像的像素,该如何解决
c#读取图像的像素
最近我在做一个有关C#处理图像的程序,因为是第一次使用C#处理图像,在读取图像像素时出现了一些问题,请各位大神们帮助看看。
上述代码在执行时,红色标识部分读取有些图像时不报错,读取有些图像时却报错。请问这是为什么??
------解决方案--------------------
要提供报错内容的细节
最近我在做一个有关C#处理图像的程序,因为是第一次使用C#处理图像,在读取图像像素时出现了一些问题,请各位大神们帮助看看。
//读取水印图片的像素数组
Rectangle arect = new Rectangle(0, 0, a.Width, a.Height);
System.Drawing.Imaging.BitmapData aData = a.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, a.PixelFormat);
//Get the address of the first line.
IntPtr aptr = aData.Scan0;
// Declare an array to hold the bytes of the bitmap.
int abytes = a.Width * a.Height;//水印图像像素个数
byte[] ArgbValues = new byte[abytes];//水印图像像素数组
// Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(aptr, ArgbValues, 0, abytes);
上述代码在执行时,红色标识部分读取有些图像时不报错,读取有些图像时却报错。请问这是为什么??
------解决方案--------------------
要提供报错内容的细节