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
| '*** rapports d'échelle horiz. et verti.
Dim coeffEchelX As Single = 1.2
Dim coeffEchelY As Single = 0.8
Sub JuxtaposeImage(ByVal gr As Graphics, ByVal bmp As Bitmap, ByVal x As Integer, ByVal y As Integer)
' Start with values of parallelogram's vertex.
Dim x0 As Integer = x
Dim y0 As Integer = y
Dim x1 As Integer = CInt(x + bmp.Width * coeffEchelX)
Dim y1 As Integer = y
Dim x2 As Integer = x
Dim y2 As Integer = CInt(y + bmp.Height * coeffEchelY)
'*** Coordonnées d'au moins 3 angles de l'image.
Dim points() As Point = {New Point(x0, y0), New Point(x1, y1), New Point(x2, y2)}
'*** Dessine l'image
gr.DrawImage(bmp, points)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim gr As Graphics = Me.CreateGraphics
Dim bmp As New Bitmap("tile_maison.png")
'*** Nombres d'images à juxtaposer horiz. et verti.
Dim nbreHoriz As Integer = 3
Dim nbreVerti As Integer = 2
For x As Integer = 1 To nbreHoriz
For y As Integer = 1 To nbreVerti
JuxtaposeImage(gr, bmp, CInt(100 + (bmp.Width * coeffEchelX * x)), CInt(20 + (bmp.Height * coeffEchelY * y)))
Next
Next
'' '' Create a destination rectangle 3 times as wide and twice as tall.
' ''Dim rect As New RectangleF(20, 120, CSng(bmp.Width / 3.5), CSng(bmp.Height / 3))
'' '' Draw the enlarged bitmap.
' ''gr.DrawImage(bmp, rect)
bmp.Dispose()
gr.Dispose()
End Sub |
Partager