Dim x As Integer
Dim y As Integer
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.Format24bppRgb)
Dim offset = width Mod 4
Dim stride = width * 3 + offset
Dim newPixel(stride * height - 1) As Byte
Marshal.Copy(bmpData.Scan0, newPixel, 0, newPixel.Length)
For y = 0 To height - 1
For x = 0 To width * 3 - 1
newPixel(stride * y + x) = 255 - newPixel(stride * y + x)
Next
Marshal.Copy(newPixel, 0, bmpData.Scan0, newPixel.Length)
bitmap.UnlockBits(bmpData)
Dim num As Integer
num = stride * y + x
newPixel(num) = 255 - newPixel(num)
int width = bitmap.Width;
int height = bitmap.Height;
int offset = width % 4;
//Table de pre-calcul
byte[] tab = new byte[256];
for (int i = 0; i <= 255; i++)
{
tab[i] = (byte)(255 - i);
}
unsafe
BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, width,
height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
byte* newPixel = (byte*)(void*)bmpData.Scan0;
width *= 3;
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
newPixel[0] = tab[newPixel[0]];
newPixel++;
newPixel += offset;
bitmap.UnlockBits(bmpData);