title: How to combine an array of png images like layers using C#?
body: <p>I have an array of images named </p>
  
  <pre><code>image_&lt;somenumber&gt;_trans.png
  </code></pre>
  
  <p>All these images have transparent areas. The idea is that when put one on top each other
  they will form a nice looking image. But I have been getting a weird GDI+ related error (“A generic error occurred in GDI+”)
  and I have been going crazy. The code I'm using now can be viewed as below;</p>
  
  <pre><code>number_of_photos = 30;
  Bitmap temp = new Bitmap("background.png");//some white background 640x480 pixels
  temp.Save("temp.png", ImageFormat.Png);
  temp.Dispose();
  for (int photo_no = 0; photo_no &lt; number_of_photos; photo_no++)
  {
      Bitmap temp1 = new Bitmap("temp.png");
      Graphics gra = Graphics.FromImage(temp1);
      Bitmap new_layer = new Bitmap("image_" + photo_no + "_trans.png");
      //the images image_&lt;photo_no&gt;_trans.png are also 640x480 pixels
      gra.DrawImage(new_layer,0,0);
      temp1.Save("temp.png");//error: A generic error occurred in GDI+.
      temp1.Dispose();
   }
  </code></pre>
  
  <p>Am I doing something wrong? Thank you for your help in advance...</p>