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