title: BitmapSource.CopyPixels does two copies?
body: <p>I´ve expected an unnormal increase in memory while copiing an image with BitmapSource.CopyPixels. </p>
  
  <p>I´ve an image file pic.jpg with 2913*4744 pixels, so about 50MB with 32bpp in memory. It is loaded to a TransformedBitmap.
  Then I try to convert it to a System.Drawing.Bitmap for image processing.</p>
  
  <p>The strange thing happens when i call "tb.CopyPixels". I would expect an increase of memory of 50MB. Because the image, which has 50MB  is copied to a bytearray. But in fact I experience an increase of about 100MB, so exactly twice the amout of memory. Is there some kind of additional (intenal) Copy? What am I missing? How can I convert a Bitmapsource to a Bitmap with an increase of 50MB?</p>
  
  <p>Thanks</p>
  
  <p>Calling Code and Converting:</p>
  
  <pre><code>    System.Drawing.Bitmap bmp;    
      private void Window_Loaded(object sender, RoutedEventArgs e)
      {
          TransformedBitmap tb = new TransformedBitmap();
  
          // Create the source to use as the tb source.
          BitmapImage bi = new BitmapImage();
          bi.BeginInit();
          bi.UriSource = new Uri("pic.jpg", UriKind.Relative);
          bi.CacheOption = BitmapCacheOption.OnLoad;
          bi.EndInit();
          //' Properties must be set between BeginInit and EndInit calls.
  
          tb.BeginInit();
          tb.Source = bi;
  
          //' Set image rotation.
          RotateTransform transform = new RotateTransform(90);
          tb.Transform = transform;
          tb.EndInit();
          //' Set the Image source.
          image.Source = tb;
  
          bmp = convertToBitmap(tb);
          Console.WriteLine();
      }
  
  
      private System.Drawing.Bitmap convertToBitmap(TransformedBitmap tb)
      {
          int stride = (tb.PixelWidth * (tb.Format.BitsPerPixel / 8));
          byte[] pixels = new byte[(tb.PixelHeight * stride)];
  
          tb.CopyPixels(pixels, stride, 0);  //&lt;-- strange Memory increase of 
          //about 100MB. I expected 50MB (the image itself)
  
          System.Drawing.Bitmap myBitmap;
  
          using (MemoryStream ms = new MemoryStream(pixels))
          {
              myBitmap = new System.Drawing.Bitmap(ms);
          }
          return myBitmap;
      }
  </code></pre>