C#.net图片快速去底(去除白色背景)

public System.Drawing.Bitmap KnockOutGzf(String path)
       {
           System.Drawing.Image image = System.Drawing.Image.FromFile(path);
           System.Drawing.Bitmap bitmapProxy = new System.Drawing.Bitmap(image);
           image.Dispose();
           for (int i = 0; i < bitmapProxy.Width; i++)
           {
               for (int j = 0; j < bitmapProxy.Height; j++)
               {
                   System.Drawing.Color c = bitmapProxy.GetPixel(i, j);
                   if (!(c.R < 240 || c.G < 240 || c.B < 240))
                   {
                       bitmapProxy.SetPixel(i, j, System.Drawing.Color.Transparent);
                   }
               }
           }
           return bitmapProxy;
   }
引用:https://www.cnblogs.com/guozefeng/p/4178291.html
posted @ 2024-06-21 18:29  不经一番寒彻骨  阅读(3)  评论(0编辑  收藏  举报