[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 585
  • Last Modified:

Problem with TMetafile: The size is not kept!

Dear EE!
I want to convert a Object (like Mathtype Equation, ChemSketch Object)  from Word to Bitmap.
So I do these work:
Copy Object to Clipboard (I do it manually). Then Use TMetafile to Redraw it (I do it by Delphi): TMetafile.Assign(Clipboard) and then:
TBitmap.Width:= TMetafile.Width; TBitmap.Height:= TMetaFile.Height;
But a problem: the size of the image(width x height) is changed (become smaller)
Can you suggest me some enhanced Component or show me how to fix this problem?
Thanks much!
  • 2
1 Solution
Just a guess,

this may be because Word is using a different base measurement for the metafiles.

After your assign of the tmetafile from the clipboard, extract the MMWidth and MMHeight values

the convert these values to pixels on screen

i.e. if the mmwidth is 100 then
you need to find out what is 100mm in your screen resolution


this gives you logical pixels per inch across the screen

divide  this by 25.4 to get pixels per mm and then multiply by MMwidth value this should give you the width you need to set the bitmap to

for height use


coldboyAuthor Commented:
Thanks! But I see using Screen.Pixelperinch is more easy.
Thats fine, the only thing you have to watch out for is that delphi gets screen.pixelsperinch from a call to


now thats fine because in 99.999% of screens a pixel is square. However if you where to use the same code say to write to a printer, then its not always the case and its best to get individual measurements for X & Y.

But its fine for what your doing

Good Luck


Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now