给透明的png图片加入白色底色

                #region 给透明的png图片加入白色底色
                Image Image = Image.FromFile("路径");
                Bitmap pbitmap = new Bitmap(Image);
                Graphics g2 = Graphics.FromImage(Image);
                GraphicsPath gp = new GraphicsPath(); //新建图像路径来存储透明的点

                for (int x = 0; x < 60; x++)
                {
                    for (int y = 0; y < 60; y++)
                    {

                        Color c = pbitmap.GetPixel(x, y);

                        if (c.A == 0)
                        {
                            gp.AddRectangle(new Rectangle(x, y, 1, 1));//添加点到路径
                            g2.DrawPath(Pens.White, gp);
                        }
                        else
                        {

                        }
                    }
                }
                #endregion

猜你喜欢

转载自www.cnblogs.com/cuihongyu3503319/p/12690603.html