共用方式為


HOW TO:載入和顯示中繼檔

更新:2007 年 11 月

Image 類別繼承而來的 Metafile 類別提供了記錄、顯示和檢查向量影像的方法。

範例

若要將向量影像 (中繼檔) 顯示在螢幕上,需要有 Metafile 物件和 Graphics 物件。將檔案 (或資料流) 名稱傳遞至 Metafile 建構函式。在您建立 Metafile 物件後,將 Metafile 物件傳遞至 Graphics 物件的 DrawImage 方法。

下列範例會從 EMF (加強型中繼檔) 檔案建立 Metafile 物件,然後繪製左上角位於 (60, 10) 的影像:

下圖顯示的是在指定位置繪製的中繼檔 (Metafile)。

影像位置

Dim metafile As New Metafile("SampleMetafile.emf")
e.Graphics.DrawImage(metafile, 60, 10)

Metafile metafile = new Metafile("SampleMetafile.emf");
e.Graphics.DrawImage(metafile, 60, 10);

編譯程式碼

上述範例是專為與 Windows Form 搭配使用而設計的,而且它需要 PaintEventArgs e (即 Paint 事件處理常式的參數)。

請參閱

其他資源

使用影像、點陣圖、圖示和中繼檔