How to generate a PNG file with C#?

You can create a bitmap with the size you want, then create a Graphics object to be able to draw on the bitmap. The Clear method is the simplest way to fill the image with a color. Then save the image using the PNG format:

using (Bitmap b = new Bitmap(50, 50)) {
  using (Graphics g = Graphics.FromImage(b)) {
    g.Clear(Color.Green);
  }
  b.Save(@"C:\green.png", ImageFormat.Png);
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)