Metafile Class

Metafile Class

 

Defines a graphic metafile. A metafile contains records that describe a sequence of graphics operations that can be recorded (constructed) and played back (displayed). This class is not inheritable.

Namespace:   System.Drawing.Imaging
Assembly:  System.Drawing (in System.Drawing.dll)

System.Object
  System.MarshalByRefObject
    System.Drawing.Image
      System.Drawing.Imaging.Metafile

[SerializableAttribute]
public sealed class Metafile : Image

NameDescription
System_CAPS_pubmethodMetafile(IntPtr, Boolean)

Initializes a new instance of the Metafile class from the specified handle.

System_CAPS_pubmethodMetafile(IntPtr, EmfType)

Initializes a new instance of the Metafile class from the specified handle to a device context and an EmfType enumeration that specifies the format of the Metafile.

System_CAPS_pubmethodMetafile(IntPtr, EmfType, String)

Initializes a new instance of the Metafile class from the specified handle to a device context and an EmfType enumeration that specifies the format of the Metafile. A string can be supplied to name the file.

System_CAPS_pubmethodMetafile(IntPtr, Rectangle)

Initializes a new instance of the Metafile class from the specified device context, bounded by the specified rectangle.

System_CAPS_pubmethodMetafile(IntPtr, Rectangle, MetafileFrameUnit)

Initializes a new instance of the Metafile class from the specified device context, bounded by the specified rectangle that uses the supplied unit of measure.

System_CAPS_pubmethodMetafile(IntPtr, Rectangle, MetafileFrameUnit, EmfType)

Initializes a new instance of the Metafile class from the specified device context, bounded by the specified rectangle that uses the supplied unit of measure, and an EmfType enumeration that specifies the format of the Metafile.

System_CAPS_pubmethodMetafile(IntPtr, Rectangle, MetafileFrameUnit, EmfType, String)

Initializes a new instance of the Metafile class from the specified device context, bounded by the specified rectangle that uses the supplied unit of measure, and an EmfType enumeration that specifies the format of the Metafile. A string can be provided to name the file.

System_CAPS_pubmethodMetafile(IntPtr, RectangleF)

Initializes a new instance of the Metafile class from the specified device context, bounded by the specified rectangle.

System_CAPS_pubmethodMetafile(IntPtr, RectangleF, MetafileFrameUnit)

Initializes a new instance of the Metafile class from the specified device context, bounded by the specified rectangle that uses the supplied unit of measure.

System_CAPS_pubmethodMetafile(IntPtr, RectangleF, MetafileFrameUnit, EmfType)

Initializes a new instance of the Metafile class from the specified device context, bounded by the specified rectangle that uses the supplied unit of measure, and an EmfType enumeration that specifies the format of the Metafile.

System_CAPS_pubmethodMetafile(IntPtr, RectangleF, MetafileFrameUnit, EmfType, String)

Initializes a new instance of the Metafile class from the specified device context, bounded by the specified rectangle that uses the supplied unit of measure, and an EmfType enumeration that specifies the format of the Metafile. A string can be provided to name the file.

System_CAPS_pubmethodMetafile(IntPtr, WmfPlaceableFileHeader)

Initializes a new instance of the Metafile class from the specified handle and a WmfPlaceableFileHeader.

System_CAPS_pubmethodMetafile(IntPtr, WmfPlaceableFileHeader, Boolean)

Initializes a new instance of the Metafile class from the specified handle and a WmfPlaceableFileHeader. Also, the deleteWmf parameter can be used to delete the handle when the metafile is deleted.

System_CAPS_pubmethodMetafile(Stream)

Initializes a new instance of the Metafile class from the specified data stream.

System_CAPS_pubmethodMetafile(Stream, IntPtr)

Initializes a new instance of the Metafile class from the specified data stream.

System_CAPS_pubmethodMetafile(Stream, IntPtr, EmfType)

Initializes a new instance of the Metafile class from the specified data stream, a Windows handle to a device context, and an EmfType enumeration that specifies the format of the Metafile.

System_CAPS_pubmethodMetafile(Stream, IntPtr, EmfType, String)

Initializes a new instance of the Metafile class from the specified data stream, a Windows handle to a device context, and an EmfType enumeration that specifies the format of the Metafile. Also, a string that contains a descriptive name for the new Metafile can be added.

System_CAPS_pubmethodMetafile(Stream, IntPtr, Rectangle)

Initializes a new instance of the Metafile class from the specified data stream, a Windows handle to a device context, and a Rectangle structure that represents the rectangle that bounds the new Metafile.

System_CAPS_pubmethodMetafile(Stream, IntPtr, Rectangle, MetafileFrameUnit)

Initializes a new instance of the Metafile class from the specified data stream, a Windows handle to a device context, a Rectangle structure that represents the rectangle that bounds the new Metafile, and the supplied unit of measure.

System_CAPS_pubmethodMetafile(Stream, IntPtr, Rectangle, MetafileFrameUnit, EmfType)

Initializes a new instance of the Metafile class from the specified data stream, a Windows handle to a device context, a Rectangle structure that represents the rectangle that bounds the new Metafile, the supplied unit of measure, and an EmfType enumeration that specifies the format of the Metafile.

System_CAPS_pubmethodMetafile(Stream, IntPtr, Rectangle, MetafileFrameUnit, EmfType, String)

Initializes a new instance of the Metafile class from the specified data stream, a Windows handle to a device context, a Rectangle structure that represents the rectangle that bounds the new Metafile, the supplied unit of measure, and an EmfType enumeration that specifies the format of the Metafile. A string that contains a descriptive name for the new Metafile can be added.

System_CAPS_pubmethodMetafile(Stream, IntPtr, RectangleF)

Initializes a new instance of the Metafile class from the specified data stream, a Windows handle to a device context, and a RectangleF structure that represents the rectangle that bounds the new Metafile.

System_CAPS_pubmethodMetafile(Stream, IntPtr, RectangleF, MetafileFrameUnit)

Initializes a new instance of the Metafile class from the specified data stream, a Windows handle to a device context, a RectangleF structure that represents the rectangle that bounds the new Metafile, and the supplied unit of measure.

System_CAPS_pubmethodMetafile(Stream, IntPtr, RectangleF, MetafileFrameUnit, EmfType)

Initializes a new instance of the Metafile class from the specified data stream, a Windows handle to a device context, a RectangleF structure that represents the rectangle that bounds the new Metafile, the supplied unit of measure, and an EmfType enumeration that specifies the format of the Metafile.

System_CAPS_pubmethodMetafile(Stream, IntPtr, RectangleF, MetafileFrameUnit, EmfType, String)

Initializes a new instance of the Metafile class from the specified data stream, a Windows handle to a device context, a RectangleF structure that represents the rectangle that bounds the new Metafile, the supplied unit of measure, and an EmfType enumeration that specifies the format of the Metafile. A string that contains a descriptive name for the new Metafile can be added.

System_CAPS_pubmethodMetafile(String)

Initializes a new instance of the Metafile class from the specified file name.

System_CAPS_pubmethodMetafile(String, IntPtr)

Initializes a new instance of the Metafile class with the specified file name.

System_CAPS_pubmethodMetafile(String, IntPtr, EmfType)

Initializes a new instance of the Metafile class with the specified file name, a Windows handle to a device context, and an EmfType enumeration that specifies the format of the Metafile.

System_CAPS_pubmethodMetafile(String, IntPtr, EmfType, String)

Initializes a new instance of the Metafile class with the specified file name, a Windows handle to a device context, and an EmfType enumeration that specifies the format of the Metafile. A descriptive string can be added, as well.

System_CAPS_pubmethodMetafile(String, IntPtr, Rectangle)

Initializes a new instance of the Metafile class with the specified file name, a Windows handle to a device context, and a Rectangle structure that represents the rectangle that bounds the new Metafile.

System_CAPS_pubmethodMetafile(String, IntPtr, Rectangle, MetafileFrameUnit)

Initializes a new instance of the Metafile class with the specified file name, a Windows handle to a device context, a Rectangle structure that represents the rectangle that bounds the new Metafile, and the supplied unit of measure.

System_CAPS_pubmethodMetafile(String, IntPtr, Rectangle, MetafileFrameUnit, EmfType)

Initializes a new instance of the Metafile class with the specified file name, a Windows handle to a device context, a Rectangle structure that represents the rectangle that bounds the new Metafile, the supplied unit of measure, and an EmfType enumeration that specifies the format of the Metafile.

System_CAPS_pubmethodMetafile(String, IntPtr, Rectangle, MetafileFrameUnit, EmfType, String)

Initializes a new instance of the Metafile class with the specified file name, a Windows handle to a device context, a Rectangle structure that represents the rectangle that bounds the new Metafile, the supplied unit of measure, and an EmfType enumeration that specifies the format of the Metafile. A descriptive string can also be added.

System_CAPS_pubmethodMetafile(String, IntPtr, Rectangle, MetafileFrameUnit, String)

Initializes a new instance of the Metafile class with the specified file name, a Windows handle to a device context, a Rectangle structure that represents the rectangle that bounds the new Metafile, and the supplied unit of measure. A descriptive string can also be added.

System_CAPS_pubmethodMetafile(String, IntPtr, RectangleF)

Initializes a new instance of the Metafile class with the specified file name, a Windows handle to a device context, and a RectangleF structure that represents the rectangle that bounds the new Metafile.

System_CAPS_pubmethodMetafile(String, IntPtr, RectangleF, MetafileFrameUnit)

Initializes a new instance of the Metafile class with the specified file name, a Windows handle to a device context, a RectangleF structure that represents the rectangle that bounds the new Metafile, and the supplied unit of measure.

System_CAPS_pubmethodMetafile(String, IntPtr, RectangleF, MetafileFrameUnit, EmfType)

Initializes a new instance of the Metafile class with the specified file name, a Windows handle to a device context, a RectangleF structure that represents the rectangle that bounds the new Metafile, the supplied unit of measure, and an EmfType enumeration that specifies the format of the Metafile.

System_CAPS_pubmethodMetafile(String, IntPtr, RectangleF, MetafileFrameUnit, EmfType, String)

Initializes a new instance of the Metafile class with the specified file name, a Windows handle to a device context, a RectangleF structure that represents the rectangle that bounds the new Metafile, the supplied unit of measure, and an EmfType enumeration that specifies the format of the Metafile. A descriptive string can also be added.

System_CAPS_pubmethodMetafile(String, IntPtr, RectangleF, MetafileFrameUnit, String)

Initializes a new instance of the Metafile class with the specified file name, a Windows handle to a device context, a RectangleF structure that represents the rectangle that bounds the new Metafile, and the supplied unit of measure. A descriptive string can also be added.

NameDescription
System_CAPS_pubpropertyFlags

Gets attribute flags for the pixel data of this Image.(Inherited from Image.)

System_CAPS_pubpropertyFrameDimensionsList

Gets an array of GUIDs that represent the dimensions of frames within this Image.(Inherited from Image.)

System_CAPS_pubpropertyHeight

Gets the height, in pixels, of this Image.(Inherited from Image.)

System_CAPS_pubpropertyHorizontalResolution

Gets the horizontal resolution, in pixels per inch, of this Image.(Inherited from Image.)

System_CAPS_pubpropertyPalette

Gets or sets the color palette used for this Image.(Inherited from Image.)

System_CAPS_pubpropertyPhysicalDimension

Gets the width and height of this image.(Inherited from Image.)

System_CAPS_pubpropertyPixelFormat

Gets the pixel format for this Image.(Inherited from Image.)

System_CAPS_pubpropertyPropertyIdList

Gets IDs of the property items stored in this Image.(Inherited from Image.)

System_CAPS_pubpropertyPropertyItems

Gets all the property items (pieces of metadata) stored in this Image.(Inherited from Image.)

System_CAPS_pubpropertyRawFormat

Gets the file format of this Image.(Inherited from Image.)

System_CAPS_pubpropertySize

Gets the width and height, in pixels, of this image.(Inherited from Image.)

System_CAPS_pubpropertyTag

Gets or sets an object that provides additional data about the image.(Inherited from Image.)

System_CAPS_pubpropertyVerticalResolution

Gets the vertical resolution, in pixels per inch, of this Image.(Inherited from Image.)

System_CAPS_pubpropertyWidth

Gets the width, in pixels, of this Image.(Inherited from Image.)

NameDescription
System_CAPS_pubmethodClone()

Creates an exact copy of this Image.(Inherited from Image.)

System_CAPS_pubmethodCreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

Releases all resources used by this Image.(Inherited from Image.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetBounds(GraphicsUnit)

Gets the bounds of the image in the specified unit.(Inherited from Image.)

System_CAPS_pubmethodGetEncoderParameterList(Guid)

Returns information about the parameters supported by the specified image encoder.(Inherited from Image.)

System_CAPS_pubmethodGetFrameCount(FrameDimension)

Returns the number of frames of the specified dimension.(Inherited from Image.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetHenhmetafile()

Returns a Windows handle to an enhanced Metafile.

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetMetafileHeader()

Returns the MetafileHeader associated with this Metafile.

System_CAPS_pubmethodSystem_CAPS_staticGetMetafileHeader(IntPtr)

Returns the MetafileHeader associated with the specified Metafile.

System_CAPS_pubmethodSystem_CAPS_staticGetMetafileHeader(IntPtr, WmfPlaceableFileHeader)

Returns the MetafileHeader associated with the specified Metafile.

System_CAPS_pubmethodSystem_CAPS_staticGetMetafileHeader(Stream)

Returns the MetafileHeader associated with the specified Metafile.

System_CAPS_pubmethodSystem_CAPS_staticGetMetafileHeader(String)

Returns the MetafileHeader associated with the specified Metafile.

System_CAPS_pubmethodGetPropertyItem(Int32)

Gets the specified property item from this Image.(Inherited from Image.)

System_CAPS_pubmethodGetThumbnailImage(Int32, Int32, Image.GetThumbnailImageAbort, IntPtr)

Returns a thumbnail for this Image.(Inherited from Image.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodPlayRecord(EmfPlusRecordType, Int32, Int32, Byte[])

Plays an individual metafile record.

System_CAPS_pubmethodRemovePropertyItem(Int32)

Removes the specified property item from this Image.(Inherited from Image.)

System_CAPS_pubmethodRotateFlip(RotateFlipType)

Rotates, flips, or rotates and flips the Image.(Inherited from Image.)

System_CAPS_pubmethodSave(Stream, ImageCodecInfo, EncoderParameters)

Saves this image to the specified stream, with the specified encoder and image encoder parameters.(Inherited from Image.)

System_CAPS_pubmethodSave(Stream, ImageFormat)

Saves this image to the specified stream in the specified format.(Inherited from Image.)

System_CAPS_pubmethodSave(String)

Saves this Image to the specified file or stream.(Inherited from Image.)

System_CAPS_pubmethodSave(String, ImageCodecInfo, EncoderParameters)

Saves this Image to the specified file, with the specified encoder and image-encoder parameters.(Inherited from Image.)

System_CAPS_pubmethodSave(String, ImageFormat)

Saves this Image to the specified file in the specified format.(Inherited from Image.)

System_CAPS_pubmethodSaveAdd(EncoderParameters)

Adds a frame to the file or stream specified in a previous call to the Save method. Use this method to save selected frames from a multiple-frame image to another multiple-frame image.(Inherited from Image.)

System_CAPS_pubmethodSaveAdd(Image, EncoderParameters)

Adds a frame to the file or stream specified in a previous call to the Save method.(Inherited from Image.)

System_CAPS_pubmethodSelectActiveFrame(FrameDimension, Int32)

Selects the frame specified by the dimension and index.(Inherited from Image.)

System_CAPS_pubmethodSetPropertyItem(PropertyItem)

Stores a property item (piece of metadata) in this Image.(Inherited from Image.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodISerializable.GetObjectData(SerializationInfo, StreamingContext)

Populates a SerializationInfo with the data needed to serialize the target object.(Inherited from Image.)

When you use the Save method to save a graphic image as a Windows Metafile Format (WMF) or Enhanced Metafile Format (EMF) file, the resulting file is saved as a Portable Network Graphics (PNG) file instead. This behavior occurs because the GDI+ component of the .NET Framework does not have an encoder that you can use to save files as .wmf or .emf files.

The following code example demonstrates how to create a Metafile and use the PlayRecord method.


using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;

// for Marshal.Copy
using System.Runtime.InteropServices; 

public class Form1 : Form
{
    private Metafile metafile1;
    private Graphics.EnumerateMetafileProc metafileDelegate;
    private Point destPoint;
    public Form1()
    {
        metafile1 = new Metafile(@"C:\Test.wmf");
        metafileDelegate = new Graphics.EnumerateMetafileProc(MetafileCallback);
        destPoint = new Point(20, 10);
    }
    protected override void OnPaint(PaintEventArgs e)
    {
        e.Graphics.EnumerateMetafile(metafile1, destPoint, metafileDelegate);
    }
    private bool MetafileCallback(
       EmfPlusRecordType recordType,
       int flags,
       int dataSize,
       IntPtr data,
       PlayRecordCallback callbackData)
    {
        byte[] dataArray = null;
        if (data != IntPtr.Zero)
        {
            // Copy the unmanaged record to a managed byte buffer 
            // that can be used by PlayRecord.
            dataArray = new byte[dataSize];
            Marshal.Copy(data, dataArray, 0, dataSize);
        }

        metafile1.PlayRecord(recordType, flags, dataSize, dataArray);

        return true;
    }

    static void Main()
    {
        Application.Run(new Form1());
    }
}

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft