首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 平面设计 > 图形图像 >

c#读取图像的像素,该如何处理

2013-03-25 
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);

上述代码在执行时,红色标识部分读取有些图像时不报错,读取有些图像时却报错。请问这是为什么?? C#?图片处理?
[解决办法]
要提供报错内容的细节

热点排行