Mirror an Image : Image Operation « 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 Operation 
17.49.2.Mirror an Image
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

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

Public Class Form1
    Inherits System.Windows.Forms.Form

    Public Sub New()
        MyBase.New()
        InitializeComponent()

    End Sub

    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

    Private components As System.ComponentModel.IContainer

    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents Button4 As System.Windows.Forms.Button
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents Panel2 As System.Windows.Forms.Panel
    <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button4 = New System.Windows.Forms.Button
        Me.Panel1 = New System.Windows.Forms.Panel
        Me.Panel2 = New System.Windows.Forms.Panel
        Me.SuspendLayout()
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(88232)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(6424)
        Me.Button2.TabIndex = 3
        Me.Button2.Text = "Mirror"
        '
        'Button4
        '
        Me.Button4.Location = New System.Drawing.Point(328232)
        Me.Button4.Name = "Button4"
        Me.Button4.Size = New System.Drawing.Size(5624)
        Me.Button4.TabIndex = 5
        Me.Button4.Text = "Exit"
        '
        'Panel1
        '
        Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Panel1.Location = New System.Drawing.Point(2416)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(200184)
        Me.Panel1.TabIndex = 10
        '
        'Panel2
        '
        Me.Panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Panel2.Location = New System.Drawing.Point(24816)
        Me.Panel2.Name = "Panel2"
        Me.Panel2.Size = New System.Drawing.Size(208184)
        Me.Panel2.TabIndex = 11
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.ClientSize = New System.Drawing.Size(464286)
        Me.Controls.Add(Me.Panel2)
        Me.Controls.Add(Me.Panel1)
        Me.Controls.Add(Me.Button4)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.Button2)
        Me.ResumeLayout(False)

    End Sub

    Dim pic1, pic2 As Bitmap


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles Button2.Click
        Panel2.Invalidate()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles Button4.Click
        End
    End Sub

    Private Sub Panel1_Paint1(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgsHandles Panel1.Paint
        Dim As Graphics = e.Graphics
        g.DrawImage(pic1, 00)
    End Sub

    Private Sub Panel2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgsHandles Panel2.Paint
        Dim As Graphics = e.Graphics
        Dim As Integer = Panel2.Width
        Dim col As Color = New Color
        
        Dim pic4 As Bitmap
        pic4 = New Bitmap(x, x)
        Dim i, j As Integer
        For i = To x - 1
            For j = To x - 1
                col = pic2.GetPixel(i, j)
                pic4.SetPixel(x - i - 1, j, col)
            Next
        Next
        g.DrawImage(pic4, 00)
        pic2 = New Bitmap(pic4)
    End Sub


    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgsHandles MyBase.Load
        Panel1.Height = Panel1.Width
        Panel2.Width = Panel1.Width
        Panel2.Height = Panel2.Width
        Dim pic As Image = Image.FromFile("YourFile.bmp")
        pic1 = New Bitmap(pic, Panel1.Width, Panel1.Height)
        pic2 = New Bitmap(pic1)
    End Sub

End Class
17.49.Image Operation
17.49.1.Rotate an Image
17.49.2.Mirror an Image
17.49.3.Move an image and paintMove an image and paint
17.49.4.Scale an imageScale an image
17.49.5.Scale image with different Graphics UnitsScale image with different Graphics Units
17.49.6.Skew imageSkew image
17.49.7.Make an image transparentMake an image transparent
17.49.8.Invert an ImageInvert an Image
17.49.9.Invert an Image unsafeInvert an Image unsafe
17.49.10.Zoom ImageZoom Image
17.49.11.Zoom and Skew an ImageZoom and Skew an Image
17.49.12.Skew an ImageSkew an Image
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.