读书人

发现了msdn的一处异常

发布时间: 2012-11-05 09:35:12 作者: rapoo

发现了msdn的一处错误

C# code
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);            System.Drawing.Imaging.BitmapData bmpData =                bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,                bmp.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) * bmp.Height;            byte[] rgbValues = new byte[bytes];            // Copy the RGB values into the array.            System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);            // Set every third value to 255. A 24bpp bitmap will look red.              for (int counter = 2; counter < rgbValues.Length; counter += 3)                rgbValues[counter] = 255;            // Copy the RGB values back to the bitmap            System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes);            // Unlock the bits.            bmp.UnlockBits(bmpData);

http://msdn.microsoft.com/zh-cn/library/5ey6h79d.aspx

[解决办法]
最下面不是有个“社区内容”嘛,你可以反馈下。
[解决办法]
折算什么bug,这只是个示例而已,没必要考虑那么仔细,具体的细节是你编程时要考虑的
[解决办法]
这只是个demo而已,而且你说的不是3的倍数的情况不是他们考虑的范围内。

不过你这种精神很不错,赞一个!

读书人网 >C#

热点推荐