vb.net 按钮图片问题
这种图片怎么才能在vb.net里用啊~~!!高手帮忙!!!http://zhidao.baidu.com/question/120892792.html?si=6这个代码...
这种图片怎么才能在vb.net里用啊~~!!高手帮忙!!!
http://zhidao.baidu.com/question/120892792.html?si=6这个代码问题好多啊,看不懂,能不能再准确详细点哪,拜托了!!
别怪我菜啊~~我都不知道代码放哪……
我方在public class form1里提示有十三个错误!!
高手来帮我啊…… 展开
http://zhidao.baidu.com/question/120892792.html?si=6这个代码问题好多啊,看不懂,能不能再准确详细点哪,拜托了!!
别怪我菜啊~~我都不知道代码放哪……
我方在public class form1里提示有十三个错误!!
高手来帮我啊…… 展开
3个回答
展开全部
在窗体上放一个Button和一个picturebox,然后打开代码编辑,把所有的代码都删掉,然后把下面的程序完整地复制过去。把这张图片放到D盘根目录下,重命名为a.jpg.然后按F5。。。恭喜你成功了!
----------------复制以下---------------------
Imports System.Drawing
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Function CutImage(ByVal start As Point, ByVal ends As Point, ByVal b As Bitmap) As Bitmap
Dim f As New Bitmap(ends.X - start.X + 1, ends.Y - start.Y + 1)
For i As Integer = start.X To ends.X
For j As Integer = start.Y To ends.Y
Dim c As Color = b.GetPixel(i, j)
f.SetPixel(i - start.X, j - start.Y, c)
Next
Next
Return f
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Image = CutImage(New Point(0, 0), New Point(99, 78), System.Drawing.Bitmap.FromFile("D:\a.jpg"))
End Sub
End Class
--------------------复制以上-----------------------
需要裁剪部分图片时这样做就好,假设每个图片的大小是100*100
PictureBox1.Image = CutImage(New Point(0,第n - 1个按钮 * 100 - 1), New Point(100, 第n个按钮 * 100 - 1), 按钮存在的位图)
---------------------------------------------------
你是怎么找到我的?
----------------复制以下---------------------
Imports System.Drawing
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Function CutImage(ByVal start As Point, ByVal ends As Point, ByVal b As Bitmap) As Bitmap
Dim f As New Bitmap(ends.X - start.X + 1, ends.Y - start.Y + 1)
For i As Integer = start.X To ends.X
For j As Integer = start.Y To ends.Y
Dim c As Color = b.GetPixel(i, j)
f.SetPixel(i - start.X, j - start.Y, c)
Next
Next
Return f
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Image = CutImage(New Point(0, 0), New Point(99, 78), System.Drawing.Bitmap.FromFile("D:\a.jpg"))
End Sub
End Class
--------------------复制以上-----------------------
需要裁剪部分图片时这样做就好,假设每个图片的大小是100*100
PictureBox1.Image = CutImage(New Point(0,第n - 1个按钮 * 100 - 1), New Point(100, 第n个按钮 * 100 - 1), 按钮存在的位图)
---------------------------------------------------
你是怎么找到我的?
展开全部
Public Bitmap CutImage(ByVal start As Point, ByVal end As Point, ByVal b As Bitmap)
Dim f As New Bitmap(end.X - start.X + 1, end.Y - start.Y + 1)
For i As Integer = start.X To end.X + 1
For j As Integer = start.Y To end.Y + 1
Dim c As Color = b.GetPixel(i, j)
f.SetPixel(i - start.X, j - start.Y, c)
Next
Next
Return f
End Sub
这是个公共自定义函数
start是左上角位置(point)
end是右下角位置(point)
B是要剪辑的图片(bitmap)
CutImage是返回的图片(bitmap)
Dim f As New Bitmap(end.X - start.X + 1, end.Y - start.Y + 1)
For i As Integer = start.X To end.X + 1
For j As Integer = start.Y To end.Y + 1
Dim c As Color = b.GetPixel(i, j)
f.SetPixel(i - start.X, j - start.Y, c)
Next
Next
Return f
End Sub
这是个公共自定义函数
start是左上角位置(point)
end是右下角位置(point)
B是要剪辑的图片(bitmap)
CutImage是返回的图片(bitmap)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在按键的属性找到imgge的属性,直接修改就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询