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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
'SIMPLE MODULE QUI STOCKE TON IMAGE
Module Module1
Public img As Bitmap
'TON FORM UTILSATEUR
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'APPEL À INVALIDATE
PictureBox1.Invalidate()
'RENDU DU PICTUREBOX EST DESSINE SUR UN BITMAP
PictureBox1.DrawToBitmap(Module1.img, New Rectangle(0, 0, PictureBox1.Size.Width, PictureBox1.Size.Height))
'ASSIGNE LE BMP à PICTUREBOX1.IMAGE
PictureBox1.Image = Module1.img
End Sub
Private Sub PictureBox1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim graphe As Graphics = e.Graphics
graphe.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
graphe.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
graphe.Clear(Color.White)
graphe.DrawLine(Pens.DarkBlue, x1:=5, y1:=5, x2:=105, y2:=105)
graphe.DrawEllipse(Pens.Red, rect:=New Rectangle(5, 5, 100, 100))
graphe.DrawString("Hello", New Font("Arial", 16.0F, FontStyle.Bold), Brushes.Magenta, New PointF(25, 25))
End Sub
'CODE NECESSAIRE SI PICTUREBOX1 EST RESIZE
Private Sub PictureBox1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.SizeChanged
Module1.img = New Bitmap(PictureBox1.Size.Width, PictureBox1.Size.Height)
'DESSIN =>APPEL À INVALIDATE
PictureBox1.Invalidate()
'RENDU DU PICTUREBOX EST DESSINE SUR UN BITMAP
PictureBox1.DrawToBitmap(Module1.img, New Rectangle(0, 0, PictureBox1.Size.Width, PictureBox1.Size.Height))
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Module1.img IsNot Nothing Then
Clipboard.SetImage(PictureBox1.Image)
End If
'J'EN FAIS CE QUE VEUX !!!
'BITMAP EST AFFICHE DANS PICTUREBOX2
If Clipboard.ContainsImage() Then
PictureBox2.Image = Clipboard.GetImage()
End If
End Sub
End Class
End Module
'TON FORM UTILISATEUR
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'APPEL À INVALIDATE
PictureBox1.Invalidate()
'RENDU DU PICTUREBOX EST DESSINE SUR UN BITMAP
PictureBox1.DrawToBitmap(Module1.img, New Rectangle(0, 0, PictureBox1.Size.Width, PictureBox1.Size.Height))
End Sub
Private Sub PictureBox1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim graphe As Graphics = e.Graphics
graphe.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
graphe.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
graphe.Clear(Color.White)
graphe.DrawLine(Pens.DarkBlue, x1:=5, y1:=5, x2:=105, y2:=105)
graphe.DrawEllipse(Pens.Red, rect:=New Rectangle(5, 5, 100, 100))
graphe.DrawString("Hello", New Font("Arial", 16.0F, FontStyle.Bold), Brushes.Magenta, New PointF(25, 25))
End Sub
'CODE NECESSAIRE SI PICTUREBOX1 EST RSIZE
Private Sub PictureBox1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.SizeChanged
Module1.img = New Bitmap(PictureBox1.Size.Width, PictureBox1.Size.Height)
'DESSIN =>APPEL À INVALIDATE
PictureBox1.Invalidate()
'RENDU DU PICTUREBOX EST DESSINE SUR UN BITMAP
PictureBox1.DrawToBitmap(Module1.img, New Rectangle(0, 0, PictureBox1.Size.Width, PictureBox1.Size.Height))
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Module1.img IsNot Nothing Then
Clipboard.SetImage(Module1.img)
End If
'BITMAP EST AFFICHE DANS PICTUREBOX2
If Clipboard.ContainsImage() Then
PictureBox2.Image = Clipboard.GetImage()
End If
End Sub
End Class |
Partager