Image主要实现读取图片文件(Image.FromFile)和保存图像文件(Image.Save)。

只要将图片转为Image类之后,就可以用.Net里面强大的GDI+功能

GDI+必须先要创建Graphics,一般的创建方法有Panel1.CreateGraphics

Graphics的DrawLine,DrawString,DrawImage都是十分常用的方法。

例如:

 

代码
 1 Dim oImg As Image = Image.FromFile(a.FileName)
 2 
 3 Dim x As Integer = oImg.Width / 4
 4 Dim y As Integer = oImg.Height / 4
 5 Dim w As Integer = oImg.Width / 2
 6 Dim h As Integer = oImg.Height / 2
 7 Dim oSaveImg As Image = New Bitmap(w, h)
 8 
 9 Dim g As Graphics = Graphics.FromImage(oSaveImg)
10 
11 g.DrawImage(oImg, 00New Rectangle(x, y, w, h), GraphicsUnit.Pixel)
12 g.Dispose()
13 
14 oSaveImg.Save("D:\Test.jpg", Imaging.ImageFormat.Jpeg)
15 
16 Me.PictureBox1.Image = oSaveImg

 

 

 

就能实现图片的截取。

相关文章:

  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
  • 2021-05-09
  • 2021-07-28
  • 2021-09-13
  • 2022-01-07
  • 2021-06-27
猜你喜欢
  • 2021-09-04
  • 2021-09-15
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2021-04-20
相关资源
相似解决方案