Hadjer91
-
20 avril 2013 à 21:54
yann_lo_san
Messages postés1137Date d'inscriptionlundi 17 novembre 2003StatutMembreDernière intervention23 janvier 2016
-
21 avril 2013 à 12:37
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 ??????
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);
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);