←Select platform

ChangeToWmf Method

Summary
Changes a LEADTOOLS Leadtools.RasterImage object into a Windows Metafile (WMF) and, if successful, frees the image data.
Syntax
C#
C++/CLI
Python
public static IntPtr ChangeToWmf( 
   RasterImage image 
) 
public: 
static IntPtr ChangeToWmf(  
   RasterImage^ image 
)  
def ChangeToWmf(self,image): 

Parameters

image
The source image.

Return Value

A handle to the Windows metafile (WMF) this method creates.

Remarks

This method results in only one copy of the image, and it invalidates this Leadtools.RasterImage object. You must call RasterImage.Dispose after calling this method.

This method allocates an metafile bitmap and copies the Leadtools.RasterImage object to the metafile.

When you no longer need the metafile, you can free it using the Windows DeleteMetaFile function.

This method does not support signed images.

For more information refer to RasterImage and GDI/GDI+.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
 
 
public void ChangeFromWmfExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   IntPtr hwmf; 
 
   // Load an image 
   using (RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"), 24, CodecsLoadByteOrder.BgrOrGray, 1, 1)) 
   { 
      // Change to WMF 
      hwmf = RasterImageConverter.ChangeToWmf(image); 
   } 
 
   // Convert the WMF back to a RasterImage preserving the size 
   using (RasterImage image = RasterImageConverter.ChangeFromWmf(hwmf, 0, 0)) 
   { 
      // Save it to disk 
      codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Image1_ChangeFromWmf.bmp"), RasterImageFormat.Bmp, 24); 
   } 
 
   // Clean up 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Drawing Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.