g.Dispose() canvas.Save("C:\TEMP\TEST.BMP", System.Drawing.Imaging.ImageFormat.Bmp) MyPicBox.Image = canvas
Dim canvas As New Bitmap(MyPicBox.Width, MyPicBox.Height) Using g As Graphics = Graphics.FromImage(canvas) 'Dim Rect0 = MyPicBox.ClientRectangle Dim Rect1 As New Rectangle(0, 0, MyPicBox.Width, MyPicBox.Height) Dim Rect2 As New Rectangle(MyPicBox.Width \ 4, MyPicBox.Height \ 4, MyPicBox.Width \ 2, MyPicBox.Height \ 2) g.Clear(Color.Transparent) g.FillRectangle(Brushes.Green, Rect1) g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy Using b As New SolidBrush(Color.FromArgb(0, Color.White)) g.FillEllipse(b, Rect2) End Using canvas.Save("C:\TEMP\TEST.png", System.Drawing.Imaging.ImageFormat.Png) End Using Clipboard.SetImage(canvas) Dim oldImage = MyPicBox.Image MyPicBox.Image = canvas 'oldImage?.Dispose()