←Select platform

ChangeToEmf Method

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

Parameters

image
The source image.

Return Value

A handle to the Windows enhanced metafile (EMF) 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 enhanced metafile bitmap and copies the Leadtools.RasterImage object to the enhanced metafile.

When you no longer need the enhanced metafile, you can free it using the Windows DeleteEnhMetaFile 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 ChangeFromEmfExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   IntPtr hemf; 
 
   // Load an image 
   using (RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"), 24, CodecsLoadByteOrder.BgrOrGray, 1, 1)) 
   { 
      // Change to EMF 
      hemf = RasterImageConverter.ChangeToEmf(image); 
   } 
 
   // Convert the EMF back to a RasterImage preserving the size 
   using (RasterImage image = RasterImageConverter.ChangeFromEmf(hemf, 0, 0)) 
   { 
      // Save it to disk 
      codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Image1_ChangeToEmf.bmp"), RasterImageFormat.Bmp, 24); 
   } 
 
   // Clean up 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

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

Leadtools.Drawing Assembly

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