Imports System.Drawing.Bitmap
Imports System.Drawing.Graphics
Imports System.Drawing.Font
Imports System.Drawing
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'This is my canvas....
Dim bmp As New Bitmap(800, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
Dim g As Graphics = Graphics.FromImage(bmp)
'Paint the whole canvas white...
g.FillRectangle(System.Drawing.Brushes.White, 0, 0, 800, 600)
'Create a blue rectangle...
g.FillRectangle(System.Drawing.Brushes.Blue, 0, 0, 400, 10)
'Create a green rectangle...
g.FillRectangle(System.Drawing.Brushes.Green, 400, 0, 400, 10)
'create a red rectangle...
g.FillRectangle(System.Drawing.Brushes.Red, 0, 200, 300, 10)
'create a yellow rectangle...
g.FillRectangle(System.Drawing.Brushes.Yellow, 301, 200, 500, 10)
'Text Vertical and Horizontal *************************************************************
Dim f As New System.Drawing.Font("Arial", 24, FontStyle.Regular, GraphicsUnit.Pixel) '*
Dim oBrush As System.Drawing.Brushes '*
g.TextRenderingHint = Text.TextRenderingHint.ClearTypeGridFit '*
g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality '*
Dim stringFormat As New StringFormat '*
stringFormat.FormatFlags = StringFormatFlags.DirectionVertical '*
g.DrawString("Hello World", f, oBrush.Black, 200, 150, stringFormat) '*
g.DrawString("Steve Schimsky", f, oBrush.Black, 200, 100) '*
'******************************************************************************************
'
g.FillEllipse(oBrush.Blue, 100, 100, 100, 100) '*
'*********************************************************************
'Pie Section *********************************************************
g.FillPie(oBrush.Orange, 200, 200, 100, 100, 90, 45) '*
'*********************************************************************
'Rectangle Outline... ************************************************
Dim oPen As New System.Drawing.Pen(System.Drawing.Color.SkyBlue) '*
oPen.Width = 8 '*
g.DrawRectangle(oPen, 300, 310, 200, 50) '*
'*********************************************************************
'EITHER... (A) Print directly to screen....****************************************
'bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg) '*
'OR... '*
'(B) Save to file, then load into image1... '*
bmp.Save(Server.MapPath("MyImage.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg) '*
'Load into image1... '*
Image1.ImageUrl = Server.MapPath("MyImage.jpg") '*
'**********************************************************************************
g.Dispose()
bmp.Dispose()
End Sub
End Class