企业网站怎么制作,wordpress 网址图标,郑州专业做网站企业,怎么建立网站最近公司项目用到文件树#xff0c;对于工程文件中不存在的文件#xff0c;要给予灰色显示#xff0c;如何让图片成灰色#xff0c;在网上找了个效率较高的方法#xff0c;很方便调用#xff0c;故记录。 1 public Bitmap ExColorDepth(Image image) 2 { 3 …最近公司项目用到文件树对于工程文件中不存在的文件要给予灰色显示如何让图片成灰色在网上找了个效率较高的方法很方便调用故记录。 1 public Bitmap ExColorDepth(Image image) 2 { 3 int Height image.Height; 4 int Width image.Width; 5 Bitmap bitmap new Bitmap(Width-2, Height-2); 6 Bitmap MyBitmap (Bitmap)image; 7 Color pixel; 8 for (int x 1; x Width-2; x) 9 for (int y 1; y Height-2; y)10 {11 pixel MyBitmap.GetPixel(x, y);12 int r, g, b, Result 0;13 r pixel.R;14 g pixel.G;15 b pixel.B;16 //实例程序以加权平均值法产生黑白图像 17 int iType 1;18 switch (iType)19 {20 case 0://平均值法 21 Result ((r g b) / 3);22 break;23 case 1://最大值法 24 Result r g ? r : g;25 Result Result b ? Result : b;26 break;27 case 2://加权平均值法 28 Result ((int)(0.7 * r) (int)(0.2 * g) (int)(0.1 * b));29 break;30 }31 bitmap.SetPixel(x, y, Color.FromArgb(Result, Result, Result));32 }33 return bitmap;34 } 转载于:https://www.cnblogs.com/jxcia_Lai/archive/2011/09/09/2172112.html