为什么我用picturebox显示裁剪出来的图片时,系统说内存不足呢?
vb.net吧
全部回复
仅看楼主
level 6
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim img As New Bitmap("E:\kenan.jpg")
Dim a As String = img.Width / 3
Dim b As String = img.Height / 3
PictureBox1.Image = System.Drawing.Image.FromFile("E:\kenan.jpg")
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
PictureBox2.SizeMode = PictureBoxSizeMode.Zoom
PictureBox3.SizeMode = PictureBoxSizeMode.Zoom
PictureBox4.SizeMode = PictureBoxSizeMode.Zoom
Dim rc1 As Rectangle = New Rectangle(0, 0, a, b)
Dim newImg1 As Image = img.Clone(rc1, Imaging.PixelFormat.Format32
bp
pArgb)
PictureBox2.Image = newImg1
Dim rc2 As Rectangle = New Rectangle(a, 0, (2 * a), b)
Dim newImg2 As Image = img.Clone(rc2, Imaging.PixelFormat.Format32bppArgb)
PictureBox3.Image = newImg2
Dim rc3 As Rectangle = New Rectangle((2 * a), 0, (3 * a), b)
Dim newImg3 As Image = img.Clone(rc3, Imaging.PixelFormat.Format32bppArgb)
PictureBox4.Image = newImg3
End Sub
2015年08月28日 08点08分 1
level 6
请教大神,是不是哪里出现了问题,谢谢。
2015年08月28日 08点08分 2
level 6
错误出在倒数第3行
2015年08月28日 08点08分 3
level 6
[疑问][疑问][疑问]
2015年08月28日 08点08分 4
level 6
有大神在吗?
2015年08月28日 08点08分 6
level 6
2015年08月28日 15点08分 9
你是不是用一个image储存了那个function的返回值?应该用二维数组。。
2015年08月28日 16点08分
回复
�ܿ˶���֮ŭ
:。把你的调用代码些上来
2015年08月28日 18点08分
回复
�ܿ˶���֮ŭ
: Dim img As New Bitmap("E:\kenan.jpg") PictureBox1.Image = img Dim a(2, 2) As Bitmap a(2, 2) = ClipImg(img) 是不是这样?
2015年08月29日 09点08分
level 6
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, h), 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)
2015年08月29日 09点08分 13
level 6
2015年08月29日 09点08分 14
这个异常应该是第4行导致的。前面你的Dim Img....后面添加 img.Dispose应该就好了。
2015年09月12日 13点09分
level 6
2015年08月29日 15点08分 17
应该是a.Dispose
2015年08月31日 00点08分
回复
�ܿ˶���֮ŭ
:成功了,谢谢您。[呵呵]能不能再问您一个问题:您知不知道如何把button长方形的形状变成一节竹子的形状,就是改变button的形状。
2015年08月31日 13点08分
回复 奇迹我来了哈哈 :可以用picturebox模拟
2015年08月31日 22点08分
回复
������111
:正解。还可以弄用户控件或者直接gdi+
2015年08月31日 23点08分
level 6
程序如何写如何才能像QQ那样截图
2015年09月03日 16点09分 20
1