title: Combining two PNG images into one image using .NET
body: <p>I have two (actually many) <a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics" rel="nofollow">PNG</a> (.png) images in my application. Both have transparent areas here and there.</p>
  
  <p>I want, in my application, to take both images, combine them, and display the result in a picture box. Later I want to save the result through a button.</p>
  
  <p>So far I managed to find the two images and combine them, but it seems the transparency thing won't work. I mean, if you put one image over another, only the top image is visible as the result because, apparently, the image's background is a plain white box. Which it is not.</p>
  
  <p>Here is a bit of my code:</p>
  
  <pre><code>    Dim Result As New Bitmap(96, 128)
      Dim g As Graphics = Graphics.FromImage(Result)
      Dim Name As String
      For Each Name In BasesCheckList.CheckedItems
          Dim Layer As New Bitmap(resourcesPath &amp; "Bases\" &amp; Name)
          For x = 0 To Layer.Width - 1
              For y = 0 To Layer.Height - 1
                  Result.SetPixel(x, y, Layer.GetPixel(x, y))
              Next
          Next
          Layer = Nothing
      Next
  </code></pre>
  
  <p><code>resourcesPath</code> is the path to my resources folder. <code>Bases</code> is a folder in it. And <code>Name</code> is the image's name.</p>