返回首页

lockbits。如何遍历像素?任何文件的大小限制:我是自学的初学者,我花了这个天似乎像什么。当我再次卡住,我认为我会问这里善良的人们,在代码项目。我一直想通过遍历大的像素(10K像素10K像素)1位Windows位图和决定对Lockbits。

 ' Lock the bitmap's bits and put in array

        Dim FullRect As New Rectangle(0, 0, FWBitmap.Width, FWBitmap.Height)

        Dim bmpData As System.Drawing.Imaging.BitmapData = FWBitmap.LockBits(FullRect, _

            Drawing.Imaging.ImageLockMode.ReadWrite, FWBitmap.PixelFormat)

 

        ' Get the address of the first line of bitmap.

        Dim ptr As IntPtr = bmpData.Scan0

 

        ' Declare an array to hold the bytes of the bitmap.

        Dim bytes As Integer = (bmpData.Stride) * (FWBitmap.Height)

        Dim EachByte(bytes - 1) As Byte

 

        ' Copy the bitmap's RGB values into the array.

        System.Runtime.InteropServices.Marshal.Copy(ptr, EachByte, 0, bytes)

当时我通过加强和字节内:{C}
阵列没关系(虽然Visual Studio时,往往不再是非常大的)。不过,我得到数组的像素值不会出现类似于原始位图。我怀疑我缺少明显的东西在这里!

回答

评论会员: 时间:2