salut à tous
j'ai une question comment modifier les valeur des pixels dans
une images indexée en niveau de gris de 8 bits par exemple le pixel (4,4), la fonction SetPixel ne fonctionne pas avec ce genre d'image ??????:cry:
voila mon code j'ai chargé l'image mais je ne peux plus modifier ces valeurs
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "charger l'image";
if (ofd.ShowDialog() == DialogResult.OK)
{ Bitmap bmp = new Bitmap(ofd.FileName);
int cx = bmp.Width;
int cy = bmp.Height;
Bitmap bmMono = new Bitmap(cx, cy, PixelFormat.Format8bppIndexed);
bmMono.SetResolution(bmp.HorizontalResolution,
bmp.VerticalResolution);
ColorPalette pal = bmMono.Palette;
for (int i = 0; i < pal.Entries.Length; i++)
pal.Entries[i] = Color.FromArgb(i, i, i);
bmMono.Palette = pal;
BitmapData bmd = bmMono.LockBits(
new Rectangle(Point.Empty, bmMono.Size),
ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
// Scan through the pixels, converting color to B&W
unsafe
{
Byte* pPixel = (Byte*)bmd.Scan0;
for (int y = 0; y < cy; y++)
{
for (int x = 0; x < cx; x++)
{
Color clr = bmp.GetPixel(x, y);
Byte byPixel = (byte)(( clr.R ));
pPixel[x] = byPixel;
}
pPixel += bmd.Stride;
}
}
}
bmMono.UnlockBits(bmd);
image_originale.Image = bmp;
}