1
,因为我没有任何的图像编辑软件,我将使用vb.net到水平切片的图像。有人可以帮我开始吗?切片一个jpg用vb.net
,因为我没有任何的图像编辑软件,我将使用vb.net到水平切片的图像。有人可以帮我开始吗?切片一个jpg用vb.net
在下面的代码首先加载图像,然后用新的宽度和高度创建一个新的图像,抓住图形从它对象最后得出旧图像投影到新的图像。我们得出的旧有形象上使用旧图像的尺寸,新的形象,但由于新的图像较小,其余将被关闭的画布。
Private Shared Sub CropImage(ByVal inputImagePath As String, ByVal outputImagePath As String, ByVal newHeight As Integer)
Using oldImage = System.Drawing.Image.FromFile(inputImagePath)
Using NewImage As New System.Drawing.Bitmap(oldImage.Width, newHeight)
Using G = Graphics.FromImage(NewImage)
G.DrawImage(oldImage, 0, 0, oldImage.Width, oldImage.Height)
NewImage.Save(outputImagePath, System.Drawing.Imaging.ImageFormat.Jpeg)
End Using
End Using
End Using
End Sub
+1这是非常有用的,感谢您张贴您的解决方案 – Hallaghan 2012-02-27 17:19:20