1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
Option Explicit On
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports System.IO
Public Class Form1
Inherits Form
Private chemin As String
Public Sub New()
' Cet appel est requis par le Concepteur Windows Form.
InitializeComponent()
' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
Me.Text = "Animated Gif Test"
Me.Size = New Size(300, 300)
'Dim image As Image = New Bitmap(chemin)
'Dim pb As PictureBox = New PictureBox()
'pb.Size = New Size(200, 200)
'pb.SizeMode = PictureBoxSizeMode.StretchImage
'pb.Location = New Point(100, 100)
'pb.BorderStyle = BorderStyle.Fixed3D
'pb.BackColor = Color.Aquamarine
'pb.Image = image
'Me.Controls.Add(pb)
End Sub
<STAThread()> _
Shared Sub Main()
Application.Run(New Form1())
End Sub
Private Sub btnLoadImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadImage.Click
Dim OpenFileDialog1 As OpenFileDialog = New OpenFileDialog
OpenFileDialog1.Filter = "Fichiers Images(*.gif)|*.gif"
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
chemin = OpenFileDialog1.FileName
If Len(chemin) = 0 Then
Exit Sub
Else
Call initPicBox(chemin)
End If
End If
End Sub
Sub initPicBox(ByVal chemin As String)
Dim image As Image = New Bitmap(chemin)
Me.PicBox.SizeMode = PictureBoxSizeMode.StretchImage
Me.PicBox.BorderStyle = BorderStyle.Fixed3D
Me.PicBox.BackColor = Color.Aquamarine
Me.PicBox.Image = image
Me.PicBox.Image. = image
End Sub
End Class |
Partager