Image Convert : Image « 2D Graphics « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » 2D Graphics » Image 
17.52.3.Image Convert
Image Convert
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Drawing.Imaging


public class ImageConverter
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

Public Class Form1
    Inherits System.Windows.Forms.Form
    Private curImage As Image

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    '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 NothingThen
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    '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.
    Friend WithEvents SaveFormatCombo As System.Windows.Forms.ComboBox
    Friend WithEvents ConvertToBtn As System.Windows.Forms.Button
    Friend WithEvents ViewImgBtn As System.Windows.Forms.Button
    Friend WithEvents pictureBox1 As System.Windows.Forms.PictureBox
    <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
        Me.SaveFormatCombo = New System.Windows.Forms.ComboBox
        Me.ConvertToBtn = New System.Windows.Forms.Button
        Me.ViewImgBtn = New System.Windows.Forms.Button
        Me.pictureBox1 = New System.Windows.Forms.PictureBox
        Me.SuspendLayout()
        '
        'SaveFormatCombo
        '
        Me.SaveFormatCombo.Items.AddRange(New Object() {"bmp""jpg""wmf""gif""emf"})
        Me.SaveFormatCombo.Location = New System.Drawing.Point(404214)
        Me.SaveFormatCombo.Name = "SaveFormatCombo"
        Me.SaveFormatCombo.Size = New System.Drawing.Size(9621)
        Me.SaveFormatCombo.TabIndex = 7
        Me.SaveFormatCombo.Text = "bmp"
        '
        'ConvertToBtn
        '
        Me.ConvertToBtn.Location = New System.Drawing.Point(404182)
        Me.ConvertToBtn.Name = "ConvertToBtn"
        Me.ConvertToBtn.Size = New System.Drawing.Size(9624)
        Me.ConvertToBtn.TabIndex = 6
        Me.ConvertToBtn.Text = "Convert Now"
        '
        'ViewImgBtn
        '
        Me.ViewImgBtn.Location = New System.Drawing.Point(40438)
        Me.ViewImgBtn.Name = "ViewImgBtn"
        Me.ViewImgBtn.Size = New System.Drawing.Size(8824)
        Me.ViewImgBtn.TabIndex = 5
        Me.ViewImgBtn.Text = "View Image"
        '
        'pictureBox1
        '
        Me.pictureBox1.Location = New System.Drawing.Point(430)
        Me.pictureBox1.Name = "pictureBox1"
        Me.pictureBox1.Size = New System.Drawing.Size(368328)
        Me.pictureBox1.TabIndex = 4
        Me.pictureBox1.TabStop = False
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.ClientSize = New System.Drawing.Size(504389)
        Me.Controls.Add(Me.SaveFormatCombo)
        Me.Controls.Add(Me.ConvertToBtn)
        Me.Controls.Add(Me.ViewImgBtn)
        Me.Controls.Add(Me.pictureBox1)
        Me.Name = "Form1"
        Me.Text = "GDI+ Image Convertor"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub ViewImgBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles ViewImgBtn.Click
        Dim openDlg As New OpenFileDialog   '
        openDlg.Filter = "All Image files|*.bmp;*.gif;*.jpg;*.ico;*.emf,*.wmf|Bitmap Files(*.bmp;*.gif;*.jpg;*.ico)|*.bmp;*.gif;*.jpg;*.ico|Meta Files(*.emf;*.wmf)|*.emf;*.wmf"
        Dim filter As String = openDlg.Filter
        openDlg.InitialDirectory = Environment.CurrentDirectory
        openDlg.Title = "Open Image File"
        openDlg.ShowHelp = True
        If openDlg.ShowDialog() = DialogResult.OK Then
            curImage = Image.FromFile(openDlg.FileName)
            pictureBox1.Width = curImage.Width
            pictureBox1.Height = curImage.Height
            pictureBox1.Image = curImage
            pictureBox1.Visible = True
        End If
    End Sub

    Private Sub ConvertToBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles ConvertToBtn.Click
        Dim imgStream As New System.IO.MemoryStream
        Dim imgConverter As New ImageConverter
    End Sub
End Class
17.52.Image
17.52.1.Image PropertiesImage Properties
17.52.2.Get Image PropertyItems
17.52.3.Image ConvertImage Convert
17.52.4.Save Image with different sizeSave Image with different size
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.