怎样才能在picturebox里画一个与photoshop相同效果的选区,谢谢

badboy168 2005-01-17 05:59:17
如题,谢谢
...全文
106 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
viena 2005-01-18
  • 打赏
  • 举报
回复
//是静止的 怎样才让它动起来了呢!
擦掉原来的(用异或笔重画),在新地方画,不就动了吗
badboy168 2005-01-18
  • 打赏
  • 举报
回复
是上结,哪位仁兄还有更好的办法能实现类似photoshop那种动态的选区
badboy168 2005-01-18
  • 打赏
  • 举报
回复
感谢 viena(维也纳nn-实心木头人石欠RUKYO) 和 laviewpbt(人一定要靠自己) 两位大哥
laviewpbt 2005-01-18
  • 打赏
  • 举报
回复
感谢 viena(维也纳nn-实心木头人石欠RUKYO)阿姨才对!^-^
qiaobushi@ 2005-01-17
  • 打赏
  • 举报
回复
是静止的 怎样才让它动起来了呢!
laviewpbt 2005-01-17
  • 打赏
  • 举报
回复
这个有点象,你看一下(代码比较乱啊)
picturebox+shape+timer


Dim TIM As Integer
Private Scol(15)
Private xxx1, xxx2, yyy1, yyy2, xcor0, xcor1, ycor0, ycor1 As Integer

Private Sub Form_Load()
picture1.BackColor = vbBlue
Shape1.BorderStyle = 3
Timer1.Interval = 200
Scol(0) = &H202020
Scol(1) = &H404040
Scol(2) = &H606060
Scol(3) = &H808080
Scol(4) = &HA0A0A0
Scol(5) = &HC0C0C0
Scol(6) = &HE0E0E0
Scol(7) = &HFFFFFF
Scol(8) = &HE0E0E0
Scol(9) = &HC0C0C0
Scol(10) = &HA0A0A0
Scol(11) = &H808080
Scol(12) = &H606060
Scol(13) = &H404040
Scol(14) = &H202020
Scol(15) = 0
Set Shape1.Container = picture1
picture1.ScaleMode = 3
picture1.Left = 250
End Sub

Private Sub picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > picture1.ScaleWidth Then
X = picture1.ScaleWidth
ElseIf X < 0 Then
X = 0
End If
If Y > picture1.ScaleHeight Then
Y = picture1.ScaleHeight
ElseIf Y < 0 Then
Y = 0
End If
Shape1.Visible = True
xcor0 = X: ycor0 = Y
xcor1 = 0: ycor1 = 0
xxx1 = xcor0: yyy1 = ycor0
xxx2 = xcor1: yyy2 = ycor1
Shape1.Move xcor0, ycor0, xcor1, ycor1
SetCoordinates
End Sub

Private Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
xxx2 = X - xxx1: yyy2 = Y - yyy1
xcor0 = xxx1: ycor0 = yyy1
xcor1 = xxx2: ycor1 = yyy2
If xxx2 < 0 Then
xcor0 = xxx1 + xxx2
If xcor0 < 0 Then xcor0 = 0
xcor1 = xxx1 - xcor0
End If
If yyy2 < 0 Then
ycor0 = yyy1 + yyy2
If ycor0 < 0 Then ycor0 = 0
ycor1 = yyy1 - ycor0
End If
If xcor0 + xcor1 > picture1.ScaleWidth Then xcor1 = picture1.ScaleWidth - xcor0
If ycor0 + ycor1 > picture1.ScaleHeight Then ycor1 = picture1.ScaleHeight - ycor0
Shape1.Move xcor0, ycor0, xcor1, ycor1
SetCoordinates

End If
End Sub


Private Sub SetCoordinates()
xcor1 = xcor0 + xcor1
ycor1 = ycor0 + ycor1
End Sub

Private Sub Timer1_Timer()
If Shape1.Visible = False Then Exit Sub
TIM = (TIM + 1) And 15
Shape1.BorderColor = Scol(TIM)
End Sub
viena 2005-01-17
  • 打赏
  • 举报
回复
如果画黑色线,RGB(226, 173, 176)替换为RGB(255, 255, 255)
RGB(255, 255, 255)是白色,因为Picture1.DrawMode = 7

7 VbXorPen 异或笔
用异或笔在原来的地方重画,即可擦去原来的线,还原画线以前的背景
viena 2005-01-17
  • 打赏
  • 举报
回复
Picture1是一个PictureBox
viena 2005-01-17
  • 打赏
  • 举报
回复
Option Explicit

Dim bStartDraw As Boolean
Dim startX As Single, startY As Single
Dim EndX As Single, EndY As Single

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
bStartDraw = True
startX = X
startY = Y
EndX = X
EndY = Y
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If bStartDraw Then
Picture1.DrawStyle = 2
'Picture1.ForeColor = RGB(226, 173, 176)
Picture1.DrawMode = 7
Picture1.Line (startX, startY)-(EndX, EndY), RGB(226, 173, 176), B
EndX = X
EndY = Y
Picture1.Line (startX, startY)-(EndX, EndY), RGB(226, 173, 176), B
Picture1.DrawMode = 13
End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
bStartDraw = False
End Sub
zglnew 2005-01-17
  • 打赏
  • 举报
回复
up
badboy168 2005-01-17
  • 打赏
  • 举报
回复
怎么没人呀,自己顶,不能沉,我顶,我顶,我顶顶顶~!~!
朋友们快来教我个方法
badboy168 2005-01-17
  • 打赏
  • 举报
回复
是的,1楼的兄台莫非会,请传授小弟,谢谢
laisiwei 2005-01-17
  • 打赏
  • 举报
回复
是不是那种会动的虚线的效果?

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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