title: Copy Small Bitmaps on to Large Bitmap with Transparency Blend: What is faster than graphics.DrawImage(smallBitmap, x , y)?
body: <p>I have identified this call as a bottleneck in a high pressure function. </p>
  
  <pre><code>graphics.DrawImage(smallBitmap, x , y);
  </code></pre>
  
  <p>Is there a faster way to blend small semi transparent bitmaps into a larger semi transparent one?</p>
  
  <p><strong>Example Usage:</strong></p>
  
  <pre><code>XY[] locations = GetLocs();
       Bitmap[] bitmaps = GetBmps(); //small images sizes vary approx 30px x 30px
  
          using (Bitmap large = new Bitmap(500, 500, PixelFormat.Format32bppPArgb))
          using (Graphics largeGraphics = Graphics.FromImage(large))
          {
            for(var i=0; i &lt; largeNumber; i++)
            {
              //this is the bottleneck
              largeGraphics.DrawImage(bitmaps[i], locations[i].x , locations[i].y); 
           }
         }
  
         var done = new MemoryStream(); 
         large.Save(done, ImageFormat.Png); 
         done.Position = 0;
         return (done);
  </code></pre>
  
  <p>The DrawImage calls take a small 32bppPArgb bitmaps and copies them into a larger bitmap at locations that vary and the small bitmaps might only partially overlap the larger bitmaps visible area.  Both images have semi transparent contents that get blended by DrawImage in a way that is important to the output.  I've done some testing with BitBlt but not seen significant speed improvement and the alpha blending didn't come out the same in my tests.    I'm open to just about any method including a better call to bitblt or unsafe c# code.  </p>