高分求助~有关PICTURE的问题

naka 2005-11-09 10:41:48
我要做一个程序,用PICTURE载入图片,但打开的图片必须居中,而且要有画笔功能
现在的问题是要居中,必须把图片放在IMAGE控件中,但是IMAGE控件却不能有画笔功能
怎么办呢?
居中:
Image1.Picture = LoadPicture(sFName)
Image1.Move (picMain.Width - Image1.Width) / 2, (picMain.Height - Image1.Height) / 2
画笔:
picMain.Line (sX, sY)-(x, y), tColors.lFCol
但二者却不能兼容,头疼阿头疼
...全文
192 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fishmans 2005-11-10
  • 打赏
  • 举报
回复
抢分的都这么快!!!!!
fishmans 2005-11-10
  • 打赏
  • 举报
回复
居中应该是:
Pictest.PaintPicture Image1.Picture, (Picture1.scaleWidth-image1.width)/2,(Picture1.scaleheight-image1.height)/2,image1.width,image1.height

呵呵,蹭点分~
northwolves 2005-11-09
  • 打赏
  • 举报
回复
通过一个临时图片框进行复制:

'Add a picturebox to Form1,Then add the following codes:

Dim drawing As Boolean

Private Sub picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
drawing = True
Picture1.CurrentX = X
Picture1.CurrentY = Y
End Sub

Private Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If drawing = True Then Picture1.Line -(X, Y)
End Sub



Private Sub Form_Load()
Picture1.Move 200, 200, Me.Width - 400, Me.Height - 400
Picture1.AutoRedraw = True
loadpic "C:\My Documents\My Pictures\img.jpg"
End Sub


Sub loadpic(ByVal picpath As String)
Dim pic As PictureBox
Set pic = Me.Controls.Add("vb.picturebox", "pic", Me)
pic.AutoRedraw = True
pic.AutoSize = True
pic.Visible = True
pic.Picture = LoadPicture(picpath)
Picture1.PaintPicture pic.Picture, (Picture1.Width - pic.Width) / 2, (Picture1.Height - pic.Height) / 2, pic.Width, pic.Height, 0, 0, pic.Width, pic.Height, vbSrcCopy
Me.Controls.Remove pic
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
drawing = False
End Sub
rainstormmaster 2005-11-09
  • 打赏
  • 举报
回复
呵呵,这个好办,你用一个picturebox(假设名为pictest),一个image,2者一样大小(然后将picturebox覆盖在image控件上,然后将image隐藏(其实藏不藏无所谓,反正image控件看不见),然后加一句:
Pictest.PaintPicture Image1.Picture, 0, 0, Picture1.Width, Picture1.Height

7,762

社区成员

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

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