Dim width As Integer = bitmap.Width
Dim height As Integer = bitmap.Height
Dim bmpData As BitmapData = bitmap.LockBits(New Rectangle(0, 0, width, height) _
, System.Drawing.Imaging.ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb)
Marshal.WriteByte(bmpData.Scan0, bmpData.Stride, 255)
Marshal.WriteByte(bmpData.Scan0, bmpData.Stride + 4, 0)
bitmap.UnlockBits(bmpData)
Dim swap As Byte
For y = 0 To height - 1
For x = 0 To width - 1
swap = Marshal.ReadByte(bmpData.Scan0, (bmpData.Stride * y) + (4 * x) + 2)
Marshal.WriteByte(bmpData.Scan0, (bmpData.Stride * y) + (4 * x) + 2 _
, Marshal.ReadByte(bmpData.Scan0, (bmpData.Stride * y) + (4 * x) + 1))
Marshal.WriteByte(bmpData.Scan0, (bmpData.Stride * y) + (4 * x) + 1, swap)
Next
Dim x As Integer
Dim y As Integer
Dim newPixel(width * height * 4 - 1) As Byte
Marshal.Copy(bmpData.Scan0, newPixel, 0, newPixel.Length)
swap = newPixel((width * y + x) * 4 + 2)
newPixel((width * y + x) * 4 + 2) _
= newPixel((width * y + x) * 4 + 1)
newPixel((width * y + x) * 4 + 1) = swap
Marshal.Copy(newPixel, 0, bmpData.Scan0, newPixel.Length)