Search code examples
windowsdelphigdi+rtf.emf

Converting the EMR_LINETO (X,Y) coordinates to twips


I am working on converting the EMF file to RTF file.

I am having a problem on converting the (x,y) coordinates (in EMR_LINETO record) to twips.

So please post the conversion factor.


Solution

  • A Twip is twentieth of a point, a point is 1/72 of an inch. So if there's no scaling in the metafile a twip should be 1/1440 of an inch. If you're converting from, say, screen pixels to twips, you'd use GetDeviceCaps to find out the number of pixels per inch. So;

    TwipsX = PixelsX * 1440 div GetDeviceCaps(DC, LOGPIXELSX);