0
什麼是調整圖片箱中圖片縮放距離的方法?放大圖片箱中的圖片
我加載從文件的圖像到一個PictureBox,這裏是我的代碼...
Dim fs As FileStream
OpenFileDialog1.Filter = "JPG files (*.jpg)|*.jpg|" & "BMP Files (*.bmp)|*.bmp|" _
& "TIF Files (*.tif)|*.tif|" & "PNG Files (*.png)|*.png|" & "ALL Files (*.*)|*.*"
OpenFileDialog1.Title = "Select an Image File"
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
currentfilename = OpenFileDialog1.FileName
If currentfilename.ToUpper.EndsWith(".JPG") Or _
currentfilename.ToUpper.EndsWith(".BMP") Or _
currentfilename.ToUpper.EndsWith(".TIF") Or _
currentfilename.ToUpper.EndsWith(".PNG") Then
If Not (Pic.Image Is Nothing) Then
Pic.Image.Dispose()
Pic.Image = Nothing
End If
fs = New FileStream(currentfilename, IO.FileMode.Open, IO.FileAccess.Read)
Pic.Image = Image.FromStream(fs)
original = Pic.Image
End If
End If
然後我調整使用此代碼變焦距離...
If original Is Nothing Then
Exit Sub
End If
If Not converted Is Nothing Then
converted.Dispose()
End If
If Not zoomImage Is Nothing Then
zoomImage.Dispose()
End If
zoomImage = New Bitmap(original, _
(Convert.ToInt64(original.Width * (ZoomValue)/100)), _
(Convert.ToInt64(original.Height * (ZoomValue/100))))
converted = Graphics.FromImage(zoomImage)
converted.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
Pic.Image = Nothing
Pic.Image = zoomImage
我沒有這個問題,如果我只是使用小圖像,但它使用大量的內存,如果我有一個大的圖像,例如,我顯示的一個圖像是一個1.5MB的TIFF文件,有一個尺寸爲33000 x 4000.我只想調整圖像的縮放級別,我不需要像在圖像上繪製任何東西,改變顏色像素或任何其他操作。