| 12
 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
 
 |  
Imports System.Drawing.Drawing2D
 
Public Class Form1
 
    Private bmpBack As Bitmap
    Private bmpFront As Bitmap
 
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
        'bitmap de background inalterable
        bmpBack = My.Resources.img1
        bmpBack = New Bitmap(bmpBack, 200, 200) ' on resize le bitmap background convenablement
 
        PictureBox1.Image = bmpBack ' on l'assigne à Image
        PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
 
        'bitmap de front scalable et dessine dans event Paint
        bmpFront = My.Resources.img2
        bmpFront = New Bitmap(bmpFront, 200, 200) ' on resize le bitmap scalable convenablement
 
        'rect 
        rectScale = New RectangleF(0, 0, 200, 200)
 
    End Sub
 
    Private increment As Single = 2.5
    Private rectScale As RectangleF
    Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
        If e.Delta = 120 Then
 
            rectScale.Inflate(increment, increment)
            rectScale.Width = Math.Min(rectScale.Width, 400) 'taille max souhaite
            rectScale.Height = Math.Min(rectScale.Height, 400)
        ElseIf e.Delta = -120 Then
            rectScale.Inflate(-increment, -increment)
            rectScale.Width = Math.Max(rectScale.Width, 50) 'taille min souhaite
            rectScale.Height = Math.Max(rectScale.Height, 50)
 
        End If
 
        PictureBox1.Invalidate()
 
 
 
    End Sub
 
    Private Sub PictureBox1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
        Dim gr As Graphics = e.Graphics
        Dim m As New Matrix
 
        gr.DrawImage(bmpFront, rectScale.X, rectScale.Y, rectScale.Width, rectScale.Height)
 
 
    End Sub
End Class | 
Partager