Metafile クラス

定義

グラフィック メタファイルを定義します。 メタファイルには、記録 (構築) して再生 (表示) できる一連のグラフィックス操作を記述するレコードが格納されています。 このクラスは継承できません。

public ref class Metafile sealed : System::Drawing::Image
public sealed class Metafile : System.Drawing.Image
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public sealed class Metafile : System.Drawing.Image
[System.Serializable]
public sealed class Metafile : System.Drawing.Image
type Metafile = class
    inherit Image
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Serializable>]
type Metafile = class
    inherit Image
[<System.Serializable>]
type Metafile = class
    inherit Image
Public NotInheritable Class Metafile
Inherits Image
継承
属性

次のコード例では、 メソッドを作成 Metafile して使用する方法を PlayRecord 示します。


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());
    }
}
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Windows.Forms
' for Marshal.Copy
Imports System.Runtime.InteropServices


Public Class Form1
    Inherits Form
    Private metafile1 As Metafile
    Private metafileDelegate As Graphics.EnumerateMetafileProc
    Private destPoint As Point
    
    Public Sub New() 
        metafile1 = New Metafile("C:\test.wmf")
        metafileDelegate = New Graphics.EnumerateMetafileProc(AddressOf MetafileCallback)
        destPoint = New Point(20, 10)
    
    End Sub
    
    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) 
        e.Graphics.EnumerateMetafile(metafile1, destPoint, metafileDelegate)
    
    End Sub
    
    Private Function MetafileCallback(ByVal recordType As _
        EmfPlusRecordType, ByVal flags As Integer, ByVal dataSize As Integer, _
        ByVal data As IntPtr, ByVal callbackData As PlayRecordCallback) As Boolean

        Dim dataArray As Byte() = Nothing
        If data <> IntPtr.Zero Then

            ' 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)
        End If

        metafile1.PlayRecord(recordType, flags, dataSize, dataArray)
        Return True

    End Function
    
    Shared Sub Main() 
        Application.Run(New Form1())
    End Sub

End Class

注釈

メソッドを Save 使用してグラフィック イメージを Windows メタファイル形式 (WMF) または拡張メタファイル形式 (EMF) ファイルとして保存すると、結果のファイルは代わりにポータブル ネットワーク グラフィックス (PNG) ファイルとして保存されます。 この動作は、.NET Frameworkの GDI+ コンポーネントに、ファイルを .wmf または .emf ファイルとして保存するために使用できるエンコーダーがないために発生します。

Note

.NET 6 以降のバージョンでは、この種類を含む System.Drawing.Common パッケージは Windows オペレーティング システムでのみサポートされています。 クロスプラットフォーム アプリでこの型を使用すると、コンパイル時の警告と実行時例外が発生します。 詳細については、「 Windows でのみサポートされる System.Drawing.Common」を参照してください。

コンストラクター

Metafile(IntPtr, Boolean)

ハンドルを指定して Metafile クラスの新しいインスタンスを初期化します。

Metafile(IntPtr, EmfType)

デバイス コンテキストを識別するハンドルおよび Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。

Metafile(IntPtr, EmfType, String)

デバイス コンテキストを識別するハンドルおよび Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。 ファイルの名前を文字列で指定できます。

Metafile(IntPtr, Rectangle)

デバイス コンテキスト、およびそのデバイス コンテキストの範囲を示す四角形を指定して、Metafile クラスの新しいインスタンスを初期化します。

Metafile(IntPtr, Rectangle, MetafileFrameUnit)

デバイス コンテキスト、および指定した測定単位を使用してそのデバイス コンテキストの範囲を示す四角形を指定して、Metafile クラスの新しいインスタンスを初期化します。

Metafile(IntPtr, Rectangle, MetafileFrameUnit, EmfType)

デバイス コンテキスト、指定した測定単位を使用してそのデバイス コンテキストの範囲を示す四角形、Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。

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

デバイス コンテキスト、指定した測定単位を使用してそのデバイス コンテキストの範囲を示す四角形、Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。 ファイルの名前を文字列で指定できます。

Metafile(IntPtr, RectangleF)

デバイス コンテキスト、およびそのデバイス コンテキストの範囲を示す四角形を指定して、Metafile クラスの新しいインスタンスを初期化します。

Metafile(IntPtr, RectangleF, MetafileFrameUnit)

デバイス コンテキスト、および指定した測定単位を使用してそのデバイス コンテキストの範囲を示す四角形を指定して、Metafile クラスの新しいインスタンスを初期化します。

Metafile(IntPtr, RectangleF, MetafileFrameUnit, EmfType)

デバイス コンテキスト、指定した測定単位を使用してそのデバイス コンテキストの範囲を示す四角形、Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。

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

デバイス コンテキスト、指定した測定単位を使用してそのデバイス コンテキストの範囲を示す四角形、Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。 ファイルの名前を文字列で指定できます。

Metafile(IntPtr, WmfPlaceableFileHeader)

ハンドルと WmfPlaceableFileHeader を指定して Metafile クラスの新しいインスタンスを初期化します。

Metafile(IntPtr, WmfPlaceableFileHeader, Boolean)

ハンドルと WmfPlaceableFileHeader を指定して Metafile クラスの新しいインスタンスを初期化します。 また、メタファイルを削除するときに、deleteWmf パラメーターを使用してハンドルを削除できます。

Metafile(Stream)

指定したデータ ストリームで Metafile クラスの新しいインスタンスを初期化します。

Metafile(Stream, IntPtr)

指定したデータ ストリームで Metafile クラスの新しいインスタンスを初期化します。

Metafile(Stream, IntPtr, EmfType)

データ ストリーム、デバイス コンテキストを識別する Windows ハンドル、および Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。

Metafile(Stream, IntPtr, EmfType, String)

データ ストリーム、デバイス コンテキストを識別する Windows ハンドル、および Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。 また、新しい Metafile を説明する名前が含まれた文字列を追加できます。

Metafile(Stream, IntPtr, Rectangle)

データ ストリーム、デバイス コンテキストを識別する Windows ハンドル、および新しい Metafile の範囲を示す四角形を表す Rectangle 構造体を指定して、Metafile クラスの新しいインスタンスを初期化します。

Metafile(Stream, IntPtr, Rectangle, MetafileFrameUnit)

データ ストリーム、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す Rectangle 構造体、および測定単位を指定して、Metafile クラスの新しいインスタンスを初期化します。

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

データ ストリーム、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す Rectangle 構造体、測定単位、および Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。

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

データ ストリーム、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す Rectangle 構造体、測定単位、および Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。 新しい Metafile を説明する名前が含まれた文字列を追加できます。

Metafile(Stream, IntPtr, RectangleF)

データ ストリーム、デバイス コンテキストを識別する Windows ハンドル、および新しい Metafile の範囲を示す四角形を表す RectangleF 構造体を指定して、Metafile クラスの新しいインスタンスを初期化します。

Metafile(Stream, IntPtr, RectangleF, MetafileFrameUnit)

データ ストリーム、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す RectangleF 構造体、および測定単位を指定して、Metafile クラスの新しいインスタンスを初期化します。

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

データ ストリーム、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す RectangleF 構造体、測定単位、および Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。

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

データ ストリーム、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す RectangleF 構造体、測定単位、および Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。 新しい Metafile を説明する名前が含まれた文字列を追加できます。

Metafile(String)

指定したファイル名から、Metafile クラスの新しいインスタンスを初期化します。

Metafile(String, IntPtr)

指定したファイル名を使用して、Metafile クラスの新しいインスタンスを初期化します。

Metafile(String, IntPtr, EmfType)

ファイル名、デバイス コンテキストを識別する Windows ハンドル、および Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。

Metafile(String, IntPtr, EmfType, String)

ファイル名、デバイス コンテキストを識別する Windows ハンドル、および Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。 説明する文字列も追加できます。

Metafile(String, IntPtr, Rectangle)

ファイル名、デバイス コンテキストを識別する Windows ハンドル、および新しい Metafile の範囲を示す四角形を表す Rectangle 構造体を指定して、Metafile クラスの新しいインスタンスを初期化します。

Metafile(String, IntPtr, Rectangle, MetafileFrameUnit)

ファイル名、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す Rectangle 構造体、および測定単位を指定して、Metafile クラスの新しいインスタンスを初期化します。

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

ファイル名、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す Rectangle 構造体、測定単位、および Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。

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

ファイル名、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す Rectangle 構造体、測定単位、および Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。 説明する文字列も追加できます。

Metafile(String, IntPtr, Rectangle, MetafileFrameUnit, String)

ファイル名、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す Rectangle 構造体、および測定単位を指定して、Metafile クラスの新しいインスタンスを初期化します。 説明する文字列も追加できます。

Metafile(String, IntPtr, RectangleF)

ファイル名、デバイス コンテキストを識別する Windows ハンドル、および新しい Metafile の範囲を示す四角形を表す RectangleF 構造体を指定して、Metafile クラスの新しいインスタンスを初期化します。

Metafile(String, IntPtr, RectangleF, MetafileFrameUnit)

ファイル名、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す RectangleF 構造体、および測定単位を指定して、Metafile クラスの新しいインスタンスを初期化します。

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

ファイル名、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す RectangleF 構造体、測定単位、および Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。

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

ファイル名、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す RectangleF 構造体、測定単位、および Metafile の形式を指定する EmfType 列挙体を指定して、Metafile クラスの新しいインスタンスを初期化します。 説明する文字列も追加できます。

Metafile(String, IntPtr, RectangleF, MetafileFrameUnit, String)

ファイル名、デバイス コンテキストを識別する Windows ハンドル、新しい Metafile の範囲を示す四角形を表す RectangleF 構造体、および測定単位を指定して、Metafile クラスの新しいインスタンスを初期化します。 説明する文字列も追加できます。

プロパティ

Flags

この Image のピクセル データに対する属性フラグを取得します。

(継承元 Image)
FrameDimensionsList

この Image 内のフレームの大きさを表す GUID の配列を取得します。

(継承元 Image)
Height

この Image の高さ (ピクセル単位) を取得します。

(継承元 Image)
HorizontalResolution

この Image の水平方向の解像度 (1 インチあたりのピクセル数) を取得します。

(継承元 Image)
Palette

この Image に使用するカラー パレットを取得または設定します。

(継承元 Image)
PhysicalDimension

このイメージの幅と高さを取得します。

(継承元 Image)
PixelFormat

この Image のピクセル形式を取得します。

(継承元 Image)
PropertyIdList

この Image に格納されたプロパティ項目の ID を取得します。

(継承元 Image)
PropertyItems

この Image に格納されたすべてのプロパティ項目 (メタデータの一部) を取得します。

(継承元 Image)
RawFormat

この Image のファイル形式を取得します。

(継承元 Image)
Size

このイメージの幅と高さ (ピクセル単位) を取得します。

(継承元 Image)
Tag

イメージに関する追加データを提供するオブジェクトを取得または設定します。

(継承元 Image)
VerticalResolution

この Image の垂直方向の解像度 (1 インチあたりのピクセル数) を取得します。

(継承元 Image)
Width

この Image の幅 (ピクセル単位) を取得します。

(継承元 Image)

メソッド

Clone()

この Image の同一コピーを作成します。

(継承元 Image)
CreateObjRef(Type)

リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。

(継承元 MarshalByRefObject)
Dispose()

この Image によって使用されているすべてのリソースを解放します。

(継承元 Image)
Dispose(Boolean)

Image によって使用されているアンマネージド リソースを解放し、オプションでマネージド リソースも解放します。

(継承元 Image)
Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetBounds(GraphicsUnit)

指定した単位でイメージの境界を取得します。

(継承元 Image)
GetEncoderParameterList(Guid)

指定したイメージ エンコーダーでサポートされるパラメーターについての情報を返します。

(継承元 Image)
GetFrameCount(FrameDimension)

指定したディメンションのフレームの数を返します。

(継承元 Image)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetHenhmetafile()

拡張 Metafile を識別する Windows ハンドルを返します。

GetLifetimeService()
古い.

対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
GetMetafileHeader()

この MetafileHeader に関連付けられている Metafile を返します。

GetMetafileHeader(IntPtr)

指定した Metafile に関連付けられている MetafileHeader を返します。

GetMetafileHeader(IntPtr, WmfPlaceableFileHeader)

指定した Metafile に関連付けられている MetafileHeader を返します。

GetMetafileHeader(Stream)

指定した Metafile に関連付けられている MetafileHeader を返します。

GetMetafileHeader(String)

指定した Metafile に関連付けられている MetafileHeader を返します。

GetPropertyItem(Int32)

この Image の指定したプロパティ項目を取得します。

(継承元 Image)
GetThumbnailImage(Int32, Int32, Image+GetThumbnailImageAbort, IntPtr)

この Image のサムネイルを返します。

(継承元 Image)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
InitializeLifetimeService()
古い.

このインスタンスの有効期間ポリシーを制御する有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
MemberwiseClone(Boolean)

現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。

(継承元 MarshalByRefObject)
PlayRecord(EmfPlusRecordType, Int32, Int32, Byte[])

個別のメタファイル レコードを再生します。

RemovePropertyItem(Int32)

指定したプロパティ項目をこの Image から削除します。

(継承元 Image)
RotateFlip(RotateFlipType)

Image の回転、反転、または回転と反転の両方を行います。

(継承元 Image)
Save(Stream, ImageCodecInfo, EncoderParameters)

指定したエンコーダー パラメーターおよびイメージ エンコーダー パラメーターを使用して、このイメージを指定したストリームに保存します。

(継承元 Image)
Save(Stream, ImageFormat)

このイメージを、指定した形式で指定したストリームに保存します。

(継承元 Image)
Save(String)

この Image を指定したファイルまたはストリームに保存します。

(継承元 Image)
Save(String, ImageCodecInfo, EncoderParameters)

指定したエンコーダー パラメーターとイメージ エンコーダー パラメーターを使用して、指定したファイルにこの Image を保存します。

(継承元 Image)
Save(String, ImageFormat)

この Image を、指定した形式で指定したファイルに保存します。

(継承元 Image)
SaveAdd(EncoderParameters)

前の Save メソッドの呼び出しで指定されたファイルまたはストリームにフレームを追加します。 このメソッドは、多重フレーム イメージから選択したフレームを別の多重フレーム イメージに保存する場合に使用します。

(継承元 Image)
SaveAdd(Image, EncoderParameters)

前の Save メソッドの呼び出しで指定されたファイルまたはストリームにフレームを追加します。

(継承元 Image)
SelectActiveFrame(FrameDimension, Int32)

ディメンションおよびインデックスで指定されたフレームを選択します。

(継承元 Image)
SetPropertyItem(PropertyItem)

この Image に、プロパティ項目 (メタデータの一部) を格納します。

(継承元 Image)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

SerializationInfo に、オブジェクトをシリアル化するために必要なデータを設定します。

(継承元 Image)

適用対象