Mega Code Archive

 
Categories / VB.Net Tutorial / 2D Graphics
 

Draw an image

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class ImageDisplay    public Shared Sub Main         Application.Run(New FrmDisplayLogo)    End Sub End class Public Class FrmDisplayLogo    Inherits System.Windows.Forms.Form        Private Sub FrmDisplayLogo_Load(ByVal sender As _       System.Object, ByVal e As System.EventArgs) _       Handles MyBase.Load       Dim width As Integer = 200       Dim height As Integer = 200       Dim mGraphicsObject As Graphics       mGraphicsObject = Me.CreateGraphics              mGraphicsObject.DrawImage(Image.FromFile("YourImage.bmp"), 5, 5, width, height)    End Sub ' FrmDisplayLogo_Load #Region " Windows Form Designer generated code "    Public Sub New()       MyBase.New()       ' This call is required by Windows Form Designer.       InitializeComponent()       ' Add any initialization after InitializeComponent() call    End Sub ' new    'Form overrides dispose to clean up the component list.    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)       If disposing Then          If Not (components Is Nothing) Then             components.Dispose()          End If       End If       MyBase.Dispose(disposing)    End Sub    Friend WithEvents cmdSetButton As System.Windows.Forms.Button    'Required by the Windows Form Designer    Private components As System.ComponentModel.Container    'NOTE: The following procedure is required by the Windows Form Designer    'It can be modified using the Windows Form Designer.      'Do not modify it using the code editor.    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()       '       Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)       Me.ClientSize = New System.Drawing.Size(568, 273)    End Sub #End Region End Class