HOW TO:建立縮圖影像
更新:2007 年 11 月
縮圖影像是影像的縮小版本。您可以藉由呼叫 Image 物件的 GetThumbnailImage 方法來建立縮圖影像。
範例
下列範例會從 Compass.bmp 檔案建構 Image 物件。原始影像的寬度為 640 個像素,高度為 479 個像素。程式碼會建立寬度為 100 個像素,高度為 100 個像素的縮圖影像。
下圖顯示的是縮圖影像。
Dim image As New Bitmap("Compass.bmp")
Dim pThumbnail As Image = image.GetThumbnailImage(100, 100, Nothing, _
New IntPtr())
e.Graphics.DrawImage( _
pThumbnail, _
10, _
10, _
pThumbnail.Width, _
pThumbnail.Height)
Image image = new Bitmap("Compass.bmp");
Image pThumbnail = image.GetThumbnailImage(100, 100, null, new
IntPtr());
e.Graphics.DrawImage(
pThumbnail,
10,
10,
pThumbnail.Width,
pThumbnail.Height);
編譯程式碼
上述範例是專為與 Windows Form 搭配使用而設計的,而且它需要 PaintEventArgs e (即 Paint 事件處理常式的參數)。