VB中如何让PictureBox中画出的图形缩放居中 10
我使用VisualStudio2013编写程序,用picC.CreateGraphics.FillRectangle(Brushes.Blue,d,0,dw,dh)pic...
我使用Visual Studio 2013编写程序,用
picC.CreateGraphics.FillRectangle(Brushes.Blue,d, 0, dw, dh)
picC.CreateGraphics.FillRectangle(Brushes.Gray,0, dh, fw, dh)
生成图形,图形时常会大于PictureBox的大小而被切掉,而且图片不居中。设置SizeMode属性无效,我估计这个属性是针对外部图片的,那么绘制的图片该如何实现缩放居中呢?请高手指点,不生感激。 展开
picC.CreateGraphics.FillRectangle(Brushes.Blue,d, 0, dw, dh)
picC.CreateGraphics.FillRectangle(Brushes.Gray,0, dh, fw, dh)
生成图形,图形时常会大于PictureBox的大小而被切掉,而且图片不居中。设置SizeMode属性无效,我估计这个属性是针对外部图片的,那么绘制的图片该如何实现缩放居中呢?请高手指点,不生感激。 展开
2个回答
展开全部
以vb6缩放居中为例,调整PaintPicture的参数X1,Y1,X2,Y2,代码如下:
Private Sub Command1_Click()
Picture1.Circle (500, 500), 400, vbGreen
Picture1.Line (100, 100)-(1000, 1000), vbRed
Picture1.Line (100, 1000)-(1000, 100), vbBlue
End Sub
Private Sub Command2_Click()
Dim pic As StdPicture
Set pic = Picture1.Image
Picture1.Cls
Picture1.PaintPicture pic, 0, 0, Picture1.Width * 0.5, Picture1.Height * 0.5, 0, 0, Picture1.Width, Picture1.Height
End Sub
Private Sub Command1_Click()
Picture1.Circle (500, 500), 400, vbGreen
Picture1.Line (100, 100)-(1000, 1000), vbRed
Picture1.Line (100, 1000)-(1000, 100), vbBlue
End Sub
Private Sub Command2_Click()
Dim pic As StdPicture
Set pic = Picture1.Image
Picture1.Cls
Picture1.PaintPicture pic, 0, 0, Picture1.Width * 0.5, Picture1.Height * 0.5, 0, 0, Picture1.Width, Picture1.Height
End Sub
2015-01-26
展开全部
'以下是vb6缩放代码,居中,调整PaintPicture的参数X1,Y1,X2,Y2
Private Sub Command1_Click()
Picture1.Circle (500, 500), 400, vbGreen
Picture1.Line (100, 100)-(1000, 1000), vbRed
Picture1.Line (100, 1000)-(1000, 100), vbBlue
End Sub
Private Sub Command2_Click()
Dim pic As StdPicture
Set pic = Picture1.Image
Picture1.Cls
Picture1.PaintPicture pic, 0, 0, Picture1.Width * 0.5, Picture1.Height * 0.5, 0, 0, Picture1.Width, Picture1.Height
End Sub
Private Sub Command1_Click()
Picture1.Circle (500, 500), 400, vbGreen
Picture1.Line (100, 100)-(1000, 1000), vbRed
Picture1.Line (100, 1000)-(1000, 100), vbBlue
End Sub
Private Sub Command2_Click()
Dim pic As StdPicture
Set pic = Picture1.Image
Picture1.Cls
Picture1.PaintPicture pic, 0, 0, Picture1.Width * 0.5, Picture1.Height * 0.5, 0, 0, Picture1.Width, Picture1.Height
End Sub
追问
您好认真呀,非常感谢您。可不好意思我是初学者,没有注释我有点看不懂。侬不能麻烦您给我解释一下,或者讲一下思路,谢谢啦!
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |