'pick image from resource bmp = My.Resources.monimage
Imports System.Drawing.Drawing2D Public Class visiondeloin Private angleRotation As Integer Private bmp As Bitmap Public Sub New() ' Cet appel est requis par le Concepteur Windows Form. InitializeComponent() ' initialisation quelconque après l'appel InitializeComponent(). 'un picbox Me.PictureBoximg1.Dock = DockStyle.Fill 'un trackbar Me.TrackBarimg1.Dock = DockStyle.Left Me.PictureBoximg1.Image = Nothing 'pick image from resource bmp = My.Resources.image1 Me.TrackBarimg1.Minimum = 0 Me.TrackBarimg1.Maximum = 360 Me.TrackBarimg1.SmallChange = 1 Me.TrackBarimg1.LargeChange = 5 'initialise l'angle de rotation Me.angleRotation = 15 Me.TrackBar1.Value = Me.angleRotation End Sub Private Sub Pictureboximg1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBoximg1.Paint If bmp Is Nothing Then Return Dim g As Graphics = e.Graphics Dim myMatrix As Matrix = New Matrix g.PageUnit = GraphicsUnit.Pixel 'calcule le centre de rotation Dim centerBmp As Point = New Point(bmp.Width / 2, bmp.Height / 2) myMatrix.RotateAt(Me.TrackBar1.Value, centerBmp) g.Transform = myMatrix g.DrawImage(bmp, 0, 0) End Sub Private Sub TrackBarimg1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBarimg1.ValueChanged Me.PictureBox1.Invalidate() End Sub ... . .
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionImports System.Drawing.Drawing2D Public Class Form1 Private angleRotation As Integer Private bmp As Bitmap Public Sub New() ' Cet appel est requis par le Concepteur Windows Form. InitializeComponent() ' Ajoutez une initialisation quelconque après l'appel InitializeComponent(). 'un picbox Me.PictureBox1.Dock = DockStyle.Fill 'un trackbar Me.TrackBar1.Dock = DockStyle.Left Me.PictureBox1.Image = Nothing 'pick image from resource bmp = My.Resources.Nenuphars Me.TrackBar1.Minimum = 0 Me.TrackBar1.Maximum = 360 Me.TrackBar1.SmallChange = 1 Me.TrackBar1.LargeChange = 5 'initialise l'angle de rotation Me.angleRotation = 15 Me.TrackBar1.Value = Me.angleRotation End Sub Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint If bmp Is Nothing Then Return Dim g As Graphics = e.Graphics Dim myMatrix As Matrix = New Matrix g.PageUnit = GraphicsUnit.Pixel 'calcule le centre de rotation Dim centerBmp As Point = New Point(bmp.Width / 2, bmp.Height / 2) myMatrix.RotateAt(Me.TrackBar1.Value, centerBmp) g.Transform = myMatrix g.DrawImage(bmp, 0, 0) End Sub Private Sub TrackBar1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar1.ValueChanged Me.PictureBox1.Invalidate() End Sub End Class
bmp = My.Resources.monimage
jpeg = My.Resources.monimage