How to interpret the properties of the MS-EMF header object - borders, frames, devices and millimeters?
I am implementing MS-EMF rendering for a bitmap graphics tool.
Parser works fine according to the specification. But I have interpretation 2.2.9 Title object properties when rendering problem, there is not enough information in the spec.
The current MapMode is used to convert from coordinates LOGICAL
to DEVICE
. How to interpret them (especially interesting MM_ISOTROPIC
and MM_ANISOTROPIC
) you can see gdi
, for example, here .
Now I am trying to specify the position and size of the whole image:
var minPoint = new PointF(header.Bounds.Left, header.Bounds.Top);
var maxPoint = new PointF(header.Bounds.Right, header.Bounds.Bottom);
float imageWidth = maxPoint.X - minPoint.X;
float imageHeight = maxPoint.Y - minPoint.Y;
float shiftX = -minPoint.X;
float shiftY = -minPoint.Y;
var globalCanvas = new CanvasClass(options.PageWidth, options.PageHeight);
globalCanvas.RenderTransform = new DrMatrix(1, 0, 0, 1, 0, 0);
float scaleX = options.PageWidth / (maxPoint.X + shiftX);
float scaleY = options.PageHeight / (maxPoint.Y + shiftY);
float minCommonScale = Math.Min(scaleX, scaleY);
if (minCommonScale > Epsilon)
{
globalCanvas.RenderTransform.Scale(minCommonScale, minCommonScale);
}
globalCanvas.RenderTransform.Translate(shiftX, shiftY);
but I don't understand how to use all the properties - Bounds, Frame, Device and Millimeters - and the result image is stretched or the scaling is wrong or the image position is wrong.
How to interpret them?
Example
1.header:
Bounds: (0, 0) - (579, 429)
Frame: (0, 0) - (10000, 10000)
Device: 1855, 1034
Millimeters: 320, 240
and only 4 records:
SelectObject(hDC, (HGDIOBJ)GRAY_BRUSH); Ellipse(hDC, 0, 0, 99, 99); SelectObject(hDC, (HGDIOBJ)BLACK_BRUSH); Ellipse(hDC, 480, 330, 579, 429);
Result:
but we should see ex1-ethalon
Interestingly, viewers do not display the ehalon correctly, except in the standard Windows viewer:
Example
2.header:
Bounds: (960, 210) - (3396, 2429)
Frame: (6772, 1481) - (23969, 17143)
Device: 2892, 4125
Millimeters: 204, 291
result (incomplete display yet): but we see the benchmark (attention to the position of the image):
source to share
No one has answered this question yet