vb.net 画图对象问题

能不能定义几个空的graphic对象,然后在它上面加载图像和用gdi绘图,还要能清空。能复制到pictruebox上而不清空puiturebox原有的内容?就像直接用CreateGraphics()获得的一样操作简便?。
如果不行的话 有没有能代替的办法那?

参考一下下面这段代码:

        ‘ 首先picturebox1 加载一张图像

        FolderBrowserDialog1.Description = "选择图片文件夹导入图片"

        FolderBrowserDialog1.ShowDialog()

        path = FolderBrowserDialog1.SelectedPath()

        If path = "" Then Return

        strSrcFile = Dir(path & "\*.tif")

        PictureBox1.Image = Image.FromFile(path & "\" & strSrcFile)

’  然后再在picturebox1中用graphic画图而不清空原图像

            ' 建立一个画图对象

            Dim g As Graphics = Me.PictureBox1.CreateGraphics

            ‘ 定义画笔

            Dim myPen As System.Drawing.Pen = New System.Drawing.Pen(Color.Blue)

            ’ 画出矩形框并且填充颜色(颜色保持50%的透明度,使得下面原来的图片背景能看得到)

                g.DrawRectangle(myPen, New System.Drawing.Rectangle(50, 50, 30, 20))

                g.FillRectangle(New SolidBrush(Color.FromArgb(50, Color.YellowGreen)), New System.Drawing.Rectangle(50, 50, 30, 20))

               ' 最后释放画图对象

               g.Dispose()

效果大致如下图所示:

温馨提示:答案为网友推荐,仅供参考