给透明的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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM