title: Rendering a WPF canvas as a specificly sized bitmap
body: <p>I have a WPF Canvas that I want to make a bitmap of.</p>
  
  <p>Specifically, I want to render it <em>actual size</em> on a 300dpi bitmap.
  The "actual size" of the objects on the canvas is 10 <a href="http://msdn.microsoft.com/en-us/library/ms748373.aspx" rel="nofollow">device independent pixels</a> = 1" in real life.
  Theoretically, WPF device independent pixels are 96dpi.</p>
  
  <p>I've spent days trying to get this to work and am coming up flummoxed.</p>
  
  <p>My understanding is that the general procedure is roughly:  </p>
  
  <pre><code>var masterBitmap = new RenderTargetBitmap((int)(canvas.ActualWidth * ?SomeFactor?),
                                            (int)(canvas.ActualHeight * ?SomeFactor?),
                                            BitmapDpi, BitmapDpi, PixelFormats.Default);
  masterBitmap.Render(canvas);  
  </code></pre>
  
  <p>and that I need to set the canvas's LayoutTransform to a  ScaleTransform of ?SomeOtherFactor? and then do a measure and arrange of the canvas to ?SomeDesiredSize?</p>
  
  <p>What I am stuck on is what to use for the values of ?SomeFactor?, ?SomeOtherFactor? and ?SomeDesiredSize? to make this work.  <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.rendertargetbitmap.aspx" rel="nofollow">MSDN documentation</a> gives no indication of what factors to use.</p>