在vb.net2015中为什么在只用一个picturebox只显示一张图片的情况下,出现“内存不足”的错误
PublicClassForm1FunctionClipImg(inputAsBitmap)AsBitmap(,)DimwAsInteger=input.Width/3,...
Public Class Form1
Function ClipImg(input As Bitmap) As Bitmap(,)
Dim w As Integer = input.Width / 3, h As Integer = input.Height / 3
Dim ret(2, 2) As Bitmap
For i As Integer = 0 To 2
For j As Integer = 0 To 2
ret(i, j) = input.Clone(New Rectangle(w * i, h * j, (w * (i + 1)), h * (i + 1)), Imaging.PixelFormat.DontCare)------这里错误
Next
Next
Return ret
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim img As New Bitmap("E:\kenan.jpg")
PictureBox1.Image = img
Dim a(,) As Bitmap
a = ClipImg(img)
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
PictureBox2.SizeMode = PictureBoxSizeMode.Zoom
PictureBox2.Image = a(0, 0)
End Sub
End Class 展开
Function ClipImg(input As Bitmap) As Bitmap(,)
Dim w As Integer = input.Width / 3, h As Integer = input.Height / 3
Dim ret(2, 2) As Bitmap
For i As Integer = 0 To 2
For j As Integer = 0 To 2
ret(i, j) = input.Clone(New Rectangle(w * i, h * j, (w * (i + 1)), h * (i + 1)), Imaging.PixelFormat.DontCare)------这里错误
Next
Next
Return ret
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim img As New Bitmap("E:\kenan.jpg")
PictureBox1.Image = img
Dim a(,) As Bitmap
a = ClipImg(img)
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
PictureBox2.SizeMode = PictureBoxSizeMode.Zoom
PictureBox2.Image = a(0, 0)
End Sub
End Class 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询