Changes the resolution of an existing Windows Enhanced Metafile (EMF).
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim emfHandle As IntPtr
Dim xResolution As Integer
Dim yResolution As Integer
Dim value As IntPtr
value = DocumentWriter.UpdateMetaFileResolution(emfHandle, xResolution, yResolution)
|
Parameters
- emfHandle
- Handle to the source EMF
- xResolution
- New horizontal resolution
- yResolution
- New vertical resolution
Return Value
A handle to the modified Windows Enhanced Metafile (EMF).
Example
This example will load an Enhanced Metafile from disk and then change its resolution to 200 by 200 dots per inch.
Visual Basic | Copy Code |
---|
Private Shared Sub ShowMetaFileDimension(ByVal hemf As IntPtr)
Using mf As System.Drawing.Imaging.Metafile = New System.Drawing.Imaging.Metafile(hemf, False)
Console.WriteLine("Size: {0} by {1} pixels", mf.Width, mf.Height)
Console.WriteLine("Resolution: {0} by {1} pixels/inch", mf.HorizontalResolution, mf.VerticalResolution)
End Using
End Sub
|
C# | Copy Code |
---|
private static void ShowMetaFileDimension(IntPtr hemf) { // Use System.Drawing.Imaging.Metafile to load the EMF and get its information using (System.Drawing.Imaging.Metafile mf = new System.Drawing.Imaging.Metafile(hemf, false)) { Console.WriteLine("Size: {0} by {1} pixels", mf.Width, mf.Height); Console.WriteLine("Resolution: {0} by {1} pixels/inch", mf.HorizontalResolution, mf.VerticalResolution); } } //// Windows API //[DllImport("gdi32")] //private extern static IntPtr GetEnhMetaFile(string lpszMetaFile); //[DllImport("gdi32")] //private extern static int DeleteEnhMetaFile(IntPtr hemf); private static void ChangeMetaFileResolutionExample() { // Load the original meta file IntPtr hemf = GetEnhMetaFile(@"C:\Users\Public\Documents\LEADTOOLS Images\Ocr1.emf"); // Show the dimension Console.WriteLine("Original EMF dimension:"); ShowMetaFileDimension(hemf); // Change the resolution to be 200 by 200 dots/inch IntPtr hemfDest = DocumentWriter.UpdateMetaFileResolution(hemf, 200, 200); // No need for the original handle anymore DeleteEnhMetaFile(hemf); Console.WriteLine("New EMF dimension:"); ShowMetaFileDimension(hemfDest); DeleteEnhMetaFile(hemfDest); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also