彩色图象变黑白图象

Bitmap objbitmap;
int i;
int j;
Color objOldColor;
int intImgWidth;
int intImgHeight;
int intPixelColorR;
int intPixelColorG;
int intPixelColorB;
Color objNewColor;

objbitmap=(Bitmap) outlookbar.Bands[bandindex].LargeImageList.Images[this.imageIndex];
intImgWidth=objbitmap.Width;
intImgHeight=objbitmap.Height;

for(j=0;j<= intImgWidth-1;j++)
    for(i=0;i<= intImgHeight-1;i++)
    {
         objOldColor=objbitmap.GetPixel(i,j);
intPixelColorR = objOldColor.R;
intPixelColorG = objOldColor.G;
intPixelColorB = objOldColor.B;

objNewColor=Color.FromArgb(255-intPixelColorR,
255-intPixelColorG,255-intPixelColorB);
objbitmap.SetPixel(i,j,objNewColor);
    }

你可能感兴趣的:(图)