Public Shared Function Invert_Image(ByVal doImage As Bitmap) As Bitmap
Dim imageData As BitmapData = doImage.LockBits(New Rectangle(0, 0, doImage.Width, doImage.Height), _
System.Drawing.Imaging.ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb)
Dim pointer0 As IntPtr = imageData.Scan0
Dim stride As Integer = imageData.Stride
Dim pixels(doImage.Width * doImage.Height - 1) As Integer
Copy(pointer0, pixels, 0, pixels.Length)
For i As Integer = 0 To pixels.Length - 1
pixels(i) = (Not pixels(i) And &HFFFFFF) Or (pixels(i) And &HFF000000)
Next i
Copy(pixels, 0, pointer0, pixels.Length)
doImage.UnlockBits(imageData)
Return doImage
End Function
Public Shared Function Invert_Image(ByVal doImage As Bitmap) As Bitmap
Dim imageData As BitmapData = doImage.LockBits(New Rectangle(0, 0, doImage.Width, doImage.Height), _
System.Drawing.Imaging.ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb)
Dim pointer0 As IntPtr = imageData.Scan0
Dim stride As Integer = imageData.Stride
Dim pixels(doImage.Width * doImage.Height - 1) As Integer
Copy(pointer0, pixels, 0, pixels.Length)
For i As Integer = 0 To pixels.Length - 1
pixels(i) = (Not pixels(i) And &HFFFFFF) Or (pixels(i) And &HFF000000)
Next i
Copy(pixels, 0, pointer0, pixels.Length)
doImage.UnlockBits(imageData)
Return doImage
End Function
To copy to clipboard, switch view to plain text mode
Bookmarks