close
Imports System.Drawing
Imports System.Drawing.Imaging
Dim g As Image = Image.FromFile("D:\Backup\T1.jpg") '讀取原始圖檔
Dim ThisFormat As ImageFormat = g.RawFormat '取得圖檔格式
Dim FixWidth As Integer = 640 '設定修改後的寬度
Dim FixHeight As Integer = (FixWidth / g.Width) * g.Height '計算等比例縮小後的高度
Dim ImgOutput As New Bitmap(g, FixWidth, FixHeight) '宣告新的圖,並指定高度
ImgOutput.Save("D:\Backup\T1.jpg", ThisFormat) '存成指定的格式
'最後將物件釋放
g.Dispose()
ImgOutput.Dispose()
參考來源:http://www.dotblogs.com.tw/topcat/archive/2008/03/05/1224.aspx
全站熱搜
留言列表