In code window above the class Form1 write following 2 lines to import
Imports System.Drawing
Imports System.Drawing.Imaging
Now double click the button1 and write the following code in side button1_Click sub.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bm As New Bitmap(256, 256)
Dim gr As Graphics = Graphics.FromImage(bm)
gr.Clear(Color.White)
gr.DrawLine(Pens.Green, 0, 0, bm.Width - 1, bm.Height - 1)
gr.DrawLine(Pens.Blue, bm.Width - 1, 0, 0, bm.Height - 1)
bm.Save("c:\image.gif", ImageFormat.Gif)
End Sub
The image will be saved as image.gif file in C drive, and the following image will be saved
image.gif
So lets try.
0 comments:
Post a Comment