Can someone help me with this?...
I want to draw simple graphics such as rectangles or lines to a bitmap instead of using the Me.creategraphics method. The only problem is: I don't know how to draw to a bitmap.
Printable View
Can someone help me with this?...
I want to draw simple graphics such as rectangles or lines to a bitmap instead of using the Me.creategraphics method. The only problem is: I don't know how to draw to a bitmap.
here's a simple example i made for you , it makes a bitmap / then makes 4 rectangles in the bitmap ( different colours )
VB Code:
Dim bmp As New Bitmap(200, 200) '/// create a bitmap 200 x 200 in size Dim grp As Graphics = Graphics.FromImage(bmp) Dim rcts(3) As Rectangle rcts(0) = New Rectangle(0, 0, 100, 100) rcts(1) = New Rectangle(100, 0, 100, 100) rcts(2) = New Rectangle(0, 100, 100, 100) rcts(3) = New Rectangle(100, 100, 100, 100) Dim p As New Pen(Color.Red, 5) With grp .DrawRectangles(p, rcts) .FillRectangle(New SolidBrush(Color.Blue), rcts(0)) .FillRectangle(New SolidBrush(Color.Green), rcts(1)) .FillRectangle(New SolidBrush(Color.Yellow), rcts(2)) .FillRectangle(New SolidBrush(Color.Violet), rcts(3)) End With '/// test by putting the bitmap as a picturebox's image ( if you wish to do so ) PictureBox1.Image = bmp