GraphDocumentExportActionsRenderAsEnhancedMetafile Method |
Renders a document as enhanced metafile. The metafile is rendered into a stream. You can create a metafile object afterwards from that stream.
Namespace: Altaxo.Graph.GdiAssembly: AltaxoBase (in AltaxoBase.dll) Version: 4.8.3179.0 (4.8.3179.0)
Syntax public static Metafile RenderAsEnhancedMetafile(
Action<Graphics> renderingProc,
PointD2D docSize,
double sourceDpiResolution,
double outputScalingFactor,
PixelFormat pixelFormat = PixelFormat.Format32bppArgb,
Stream? stream = null
)
Parameters
- renderingProc ActionGraphics
- Procedure for rendering the document.
The argument is a graphics context, which is set to GraphicsUnits equal to Points.
The drawing must be inside of the boundaries of docSize.X and docSize.Y.
- docSize PointD2D
- Size of the document in points (1/72 inch)
- sourceDpiResolution Double
- The resolution in dpi of the source. This parameter is used only if creating the reference graphics context from the current printer fails. In this case, a context from a bitmap with the provided resolution is created.
- outputScalingFactor Double
- Output scaling factor. If less than 1, the image will appear smaller than originally, if greater than 1, the image will appear larger than originally.
- pixelFormat PixelFormat (Optional)
- Optional: Only used if the graphics context can not be created from a printer document. Pixel format of the bitmap that is used in this case to construct the graphics context.
- stream Stream (Optional)
- If not null, the metafile is rendered into this stream.
Return Value
MetafileThe rendered enhanced metafile (vector format).
Remarks
I found no other way to realize different dpi resolutions, independently of screen or printer device contexts, as to patch the resulting metafile stream with
informations about an 'artifical' device, which has exactly the resolution that is neccessary. By careful choice of the size of this artifical device one can
avoid rounding errors concerning resolution and size.
It happens that some programs (for instance MS Word 2010 when saving as PDF document) mess up the size of the metafile graphics, if the graphics was created with a PageUnit
(of the graphics context) other than PIXELS.
Thus I now always use PIXEL as PageUnit and scale the graphics context accordingly.
See Also