Problem converting MM_HIMETRIC file to wpf

I have some EMF files created with the MM_HIMETRIC mapping mode. The Y-coordinate is negative the longer down on the page I get.

When loading the file into Paste2Xaml and displaying the xaml preview, the left and top properties are negative, but nothing displays.

Is files with MM_HIMETRIC supported, or is there a workaround that could be applied?

Thank you in advance for your answer.

Sample file enclosed.

Attached Files
.zip (Size: 1.49 KB / Downloads: 2)

The MM_HIMETRIC mapping mode is currently not supported with Ab2d.ReaderWmf. I will try to add support for it in the future version (I cannot say when it will be available - I need to finish some other things first).

When using MM_HIMETRIC mapping mode the y asix is up instead of down. In this mode Ab2d.ReaderWmf wrongly adds bounds to the coordinates and wrongly calculates root canvas size.

The following code can be used as a workaround for your case (when you will use Paths or some other more complex objects it will not work any more):

Viewbox viewbox = Ab2d.ReaderWmf.Instance.Read("testfilemftowpf.emf");

Canvas rootCanvas = (Canvas)viewbox.Child;

rootCanvas.Width = 2100;
rootCanvas.Height = 2970;

int boundsX = 473;
int boundsY = 260;

foreach (UIElement oneChild in rootCanvas.Children)
    if (oneChild is Line)
        Line oneLine = (Line)oneChild;
        oneLine.X1 += boundsX;
        oneLine.X2 += boundsX;
        oneLine.Y1 = -oneLine.Y1 - boundsY;
        oneLine.Y2 = -oneLine.Y2 - boundsY;
        Canvas.SetTop(oneChild, -Canvas.GetTop(oneChild) - boundsY);
        Canvas.SetLeft(oneChild, boundsX + Canvas.GetLeft(oneChild));
Andrej Benedik

Forum Jump:

Users browsing this thread:
1 Guest(s)