vb.net中使用GDI画图,然后平移,可是平移之前的图还在,怎么去掉平移之前的,保留平移之后的?
DimagAsGraphicsag=PictureBox1.CreateGraphicsDimrectAsNewRectangle(0,0,50,50)DimpenAsN...
Dim ag As Graphics
ag = PictureBox1.CreateGraphics
Dim rect As New Rectangle(0, 0, 50, 50)
Dim pen As New Pen(Color.FromArgb(128, 200, 0, 200), 2)
ag.DrawRectangle(pen, rect)
ag.ResetTransform()
ag.TranslateTransform(150, 150)
ag.DrawRectangle(pen, rect) 展开
ag = PictureBox1.CreateGraphics
Dim rect As New Rectangle(0, 0, 50, 50)
Dim pen As New Pen(Color.FromArgb(128, 200, 0, 200), 2)
ag.DrawRectangle(pen, rect)
ag.ResetTransform()
ag.TranslateTransform(150, 150)
ag.DrawRectangle(pen, rect) 展开
展开全部
用覆盖的方法,再声明一个pen,颜色为picturebox1.backcolor。 我这里就把图片背景当成白色。
Dim ag As Graphics
Dim pen1 As New Pen(Color.FromArgb(255, 255, 255, 255), 2)
ag = PictureBox1.CreateGraphics
Dim rect As New Rectangle(0, 0, 50, 50)
Dim pen As New Pen(Color.FromArgb(255, 200, 0, 200), 2)
ag.DrawRectangle(pen, rect)
ag.DrawRectangle(pen1, rect)
ag.TranslateTransform(150, 50)
ag.DrawRectangle(pen, rect)
Dim ag As Graphics
Dim pen1 As New Pen(Color.FromArgb(255, 255, 255, 255), 2)
ag = PictureBox1.CreateGraphics
Dim rect As New Rectangle(0, 0, 50, 50)
Dim pen As New Pen(Color.FromArgb(255, 200, 0, 200), 2)
ag.DrawRectangle(pen, rect)
ag.DrawRectangle(pen1, rect)
ag.TranslateTransform(150, 50)
ag.DrawRectangle(pen, rect)
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询