Mais je ne trouve pas le moyen de faire pivoter une image, vous l'aurez compris, il s'agir de l'aiguille.
Option Explicit
Private cy As Integer
Private cx As Integer
Private diametre As Integer
Private Sub Form_Activate()
Me.ScaleMode = vbPixels
Picture1.AutoRedraw = True
Picture1.AutoSize = True
Picture1.FillStyle = 1 ' ===>> fillstyle = transparent
Picture1.Move Me.ScaleWidth / 4, Me.ScaleHeight / 4
cx = Picture1.ScaleWidth / 2
cy = Picture1.ScaleHeight / 2
diametre = cx
HScroll1.Min = 150
HScroll1.Max = -150
HScroll1.Value = HScroll1.Min
End Sub
Private Sub HScroll1_Change()
HScroll1_Scroll
End Sub
Private Sub HScroll1_Scroll()
Dim ancx As Integer, ancy As Integer
Picture1.Cls
Picture1.DrawWidth = 1
Dim pi As Double, toto As Double
pi = 4 * Atn(1)
toto = (-HScroll1.Value / 180) * pi
ancy = cy + Sin(toto - (0.5 * pi)) * diametre * 0.8
ancx = cx + Cos(toto - (0.5 * pi)) * diametre * 0.8
Picture1.DrawWidth = 3
Picture1.Line (cx, cy)-(ancx, ancy)
End Sub
Picture1.Line (cx, cy)-(ancx, ancy)
myPictureBox.Image.RotateFlip(RotateFlipType.Rotate180FlipNone)
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionOption Strict On Imports System.Math Public Class Form1 Private Sub Rotate() ' Copy the output bitmap from the source image. Dim bm_in As New Bitmap("C:\chemin fichier.jpg") ' Make an array of points defining the ' image's corners. Dim wid As Single = bm_in.Width Dim hgt As Single = bm_in.Height Dim corners As Point() = { _ New Point(0, 0), _ New Point(CInt(wid), 0), _ New Point(0, CInt(hgt)), _ New Point(CInt(wid), CInt(hgt))} ' Translate to center the bounding box at the origin. Dim cx As Single = wid / 2 Dim cy As Single = hgt / 2 Dim i As Long For i = 0 To 3 corners(CInt(i)).X = CInt(corners(CInt(i)).X - cx) corners(CInt(i)).Y = CInt(corners(CInt(i)).Y - cy) Next i ' Rotate. Dim theta As Single = CSng(Single.Parse(txtAngle.Text) * PI / 180.0) Dim sin_theta As Single = CSng(Sin(theta)) Dim cos_theta As Single = CSng(Cos(theta)) Dim X As Single Dim Y As Single For i = 0 To 3 X = corners(CInt(i)).X Y = corners(CInt(i)).Y corners(CInt(i)).X = CInt(X * cos_theta + Y * sin_theta) corners(CInt(i)).Y = CInt(-X * sin_theta + Y * cos_theta) Next i ' Translate so X >= 0 and Y >=0 for all corners. Dim xmin As Single = corners(0).X Dim ymin As Single = corners(0).Y For i = 1 To 3 If xmin > corners(CInt(i)).X Then xmin = corners(CInt(i)).X If ymin > corners(CInt(i)).Y Then ymin = corners(CInt(i)).Y Next i For i = 0 To 3 corners(CInt(i)).X = CInt(corners(CInt(i)).X - xmin) corners(CInt(i)).Y = CInt(corners(CInt(i)).Y - ymin) Next i ' Create an output Bitmap and Graphics object. Dim bm_out As New Bitmap(CInt(-2 * xmin), CInt(-2 * ymin)) Dim gr_out As Graphics = Graphics.FromImage(bm_out) ' Drop the last corner lest we confuse DrawImage, ' which expects an array of three corners. ReDim Preserve corners(2) ' Draw the result onto the output Bitmap. gr_out.DrawImage(bm_in, corners) ' Display the result. picDest.Image = bm_out End Sub Private Sub TrackBar1_Scroll(sender As System.Object, e As System.EventArgs) Handles TrackBar1.Scroll txtAngle.Text = CStr(TrackBar1.Value) Rotate() End Sub End Class
8 mai 2015 à 20:56
Encore merci! ;)