int width = bitmap.Width;
int height = bitmap.Height;
unsafe
{
BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, width,
height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
byte* newPixel = (byte*)(void*)bmpData.Scan0;
byte swap;
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
swap = newPixel[2];
newPixel[2] = newPixel[1];
newPixel[1] = swap;
newPixel += 4;
}
bitmap.UnlockBits(bmpData);
uint* newPixel = (uint*)(void*)bmpData.Scan0;
newPixel[0] = (uint)((newPixel[0] & 0x000000ff) |
(newPixel[0] & 0x0000ff00) << 8 | (newPixel[0] & 0x00ff0000) >> 8 |
(newPixel[0] & 0xff000000));
newPixel++;
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)
Dim newPixel(width * height - 1) As Integer
Marshal.Copy(bmpData.Scan0, newPixel, 0, newPixel.Length)
Dim temp As Integer
For y = 0 To height - 1
For x = 0 To width - 1
temp = newPixel(width * y + x)
newPixel(width * y + x) _
= temp And &HFF Or (temp And &HFF00) << 8 _
Or (temp And &HFF0000) >> 8 Or (temp And &HFF000000)
Next
Marshal.Copy(newPixel, 0, bmpData.Scan0, newPixel.Length)
bitmap.UnlockBits(bmpData)