?????????????????????????????C#????????????3???????Bitmap??BitmapData???Graphics????C#?????????3?????????
????Bitmap??????????????????????????????????????????????£?
????GetPixel??????SetPixel???????????????????????????????????
????PixelFormat?????????????????????
????Palette?????????????????????????????塣
????Height?????Width???????????????????
????LockBits??????UnlockBits????????????????????????е?λ??????
????BitmapData?????????λ????????
????Height???????????λ??????
????Width???????????λ??????
????PixelFormat?????????????????????
????Scan0?????????????????????????
????Stride????????????????????
?????????????
????24λ???????????????3???????????????????R??G??B????????????????????????3?????????????????????????????????????????

????Gray(I??j)??????????????(I??j)????????????????????????????????????????????????

??????????????????????????????????G????????????

??????????3???????????????????????淨(jìng)?????????????????и???????
????????????
??????????GDI+?е?Bitmap.GetPixel??Bitmap.SetPixel??????
if (bitmap != null)
{
newbitmap = bitmap.Clone() as Bitmap;
Color pixel;
int ret;
for (int x = 0; x < newbitmap.Width; x++)
{
for (int y = 0; y < newbitmap.Height; y++)
{
pixel = newbitmap.GetPixel(x?? y);
ret = (int)(pixel.R * 0.299 + pixel.G * 0.587 + pixel.B * 0.114);
newbitmap.SetPixel(x?? y?? Color.FromArgb(ret?? ret?? ret));
}
}
pictureBox1.Image = newbitmap.Clone() as Image;
}
??????淨(jìng)
??????淨(jìng)?????????????????????У???????????????????????????
if (bitmap != null)
{
newbitmap = bitmap.Clone() as Bitmap;
Rectangle rect = new Rectangle(0?? 0?? newbitmap.Width?? newbitmap.Height);
System.Drawing.Imaging.BitmapData bmpdata = newbitmap.LockBits(rect?? System.Drawing.Imaging.ImageLockMode.ReadWrite?? newbitmap.PixelFormat);
IntPtr ptr = bmpdata.Scan0;
int bytes = newbitmap.Width * newbitmap.Height * 3;
byte[] rgbvalues = new byte[bytes];
System.Runtime.InteropServices.Marshal.Copy(ptr?? rgbvalues?? 0?? bytes);
double colortemp = 0;
for (int i = 0; i < rgbvalues.Length; i += 3)
{
colortemp = rgbvalues[i + 2] * 0.299 + rgbvalues[i + 1] * 0.587 + rgbvalues[i] * 0.114;
rgbvalues[i] = rgbvalues[i + 1] = rgbvalues[i + 2] = (byte)colortemp;
}
System.Runtime.InteropServices.Marshal.Copy(rgbvalues?? 0?? ptr?? bytes);
newbitmap.UnlockBits(bmpdata);
pictureBox1.Image = newbitmap.Clone() as Image;
}