title: How do I make a bitmap version of a WMF file that is loaded into a TImage.Picture and move that to a TSpeedButton.Glyph
body: <p>For the sake of a minimal complete question, I have a WMF file loaded into a <code>TImage</code> control on a form. This control contains the property Picture, which is a <code>TPicture</code> type.  I am trying to "rasterize" the WMF file that I loaded into the TImage, and store that into a <code>TSpeedButton.Glyph</code>.</p>
  
  <p>What is interesting about this process is I am able to use this technique to create a resolution independent custom control (a button in my case) that will redraw its glyph for any resolution you like.</p>
  
  <p>In real world usage, I would not have a TImage or a TSpeedButton, but this question is fundamentally about the process of moving content from <code>TPicture</code> to a <code>TBitmap</code>. </p>
  
  <p>Here is the relevant semi-working code:</p>
  
  <pre><code>procedure CopyBitmap(  Source:TImage;  DestSpeedButton:TSpeedButton );
  var
     bmp: TBitmap;
  begin
     bmp:=TBitmap.Create;
     try
       // note: with WMF loaded, Source.Picture.Bitmap.Width and Height are 0.
       bmp.Width := Source.Width; // originally I had Source.Picture.Bitmap.Width, which didn't work.
       bmp.Height := Source.Height; //because Source.Picture.Bitmap.Height, doesn't work.
       bmp.Canvas.Draw(0,0, Source.Picture.Graphic );
       DestSpeedButton.Glyph:=bmp;
     finally
       bmp.Free;
     end;
  end;
  </code></pre>
  
  <p>Is this the correct approach? Why does the image invert during copy? </p>
  
  <p>A sample WMF file, the exact file I'm using, is found <a href="https://drive.google.com/file/d/0B07SrKpE8ErmeFcxQ3ZVLWtWWEE/edit?usp=sharing" rel="nofollow noreferrer">here</a>.</p>
  
  <p><img src="https://i.stack.imgur.com/4DjAm.png" alt="enter image description here"></p>