关于picturebox里图片选择后移动的问题

IKEA66 2010-04-15 07:51:57
用鼠标选择picturebox里图片的一部分后,我想将选中的部分移动或删除掉,怎么处理


VB新人
...全文
169 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
caomeng_sysu 2010-04-22
  • 打赏
  • 举报
回复
路过的人
IKEA66 2010-04-21
  • 打赏
  • 举报
回复
先去试试先啊
feixuyue 2010-04-20
  • 打赏
  • 举报
回复
Public Class Form1

Dim pstart As New Point
Dim pend As New Point
Dim bmpsz As New Size
Dim bmp As Bitmap

Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
pstart = e.Location
End Sub

Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
pend = e.Location
bmpsz = Point.Subtract(pend, pstart)
bmp = New Bitmap(bmpsz.Width, bmpsz.Height)
Dim g As Graphics = PictureBox1.CreateGraphics
g.DrawRectangle(New Pen(Color.Blue), New Rectangle(pstart, bmpsz))
Dim gbmp As Graphics = Graphics.FromImage(bmp)
gbmp.CopyFromScreen(PictureBox1.PointToScreen(pstart), New Point(0, 0), bmpsz)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Image = bmp
End Sub
End Class
feixuyue 2010-04-20
  • 打赏
  • 举报
回复
pictureBox1.Image = PictureBox1.DrawToBitmap(bmp, New Rectangle(0, 0, 20, 20))->
PictureBox1.DrawToBitmap(bmp, New Rectangle(0, 0, 20, 20))
IKEA66 2010-04-19
  • 打赏
  • 举报
回复
4楼能详细说明吗

这几天一直在处理此问题.怎是找到不解决方案

水哥阿乐 2010-04-19
  • 打赏
  • 举报
回复
pictureBox1.Image = PictureBox1.DrawToBitmap(bmp, New Rectangle(0, 0, 20, 20))
表达式不产生值
aiyidao1987 2010-04-19
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wuyq11 的回复:]
在picturebox的mouseDown事件里记录下点击的点
Bitmap bmp=new Bitmap(w,h);
pictureBox1.Image = pictureBox1.DrawToBitmap(bmp, new Rectangle(0, 0, 20, 20));
[/Quote]
牛!
wuyq11 2010-04-15
  • 打赏
  • 举报
回复
在picturebox的mouseDown事件里记录下点击的点
Bitmap bmp=new Bitmap(w,h);
pictureBox1.Image = pictureBox1.DrawToBitmap(bmp, new Rectangle(0, 0, 20, 20));
IKEA66 2010-04-15
  • 打赏
  • 举报
回复
怎么都没有人回啊
水哥阿乐 2010-04-15
  • 打赏
  • 举报
回复
有难度,帮顶

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧