2016-10-23 4 views
0

Dites, j'ai un PictureBox1 dans mon formulaire. Ce PictureBox a une image, et je veux le faire pivoter. En fait, j'ai appris comment faire pivoter l'image de 90.180.270 .... degré. Mais comment puis-je le faire pivoter de 20 degrés ou 45 degrés?Comment faire pivoter une image à l'intérieur de PictureBox de 20 degrés VB 2015?

C'est ce que j'ai apprendre

PictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone) 
+0

Vous devez utiliser les méthodes GDI pour le faire. Voir [cet article] (http://www.codeproject.com/Articles/58815/C-Image-PictureBox-Rotations) – FloatingKiwi

+0

Vous pouvez avoir votre réponse dans ce [sujet] (https://social.msdn.microsoft. com/Forums/vstudio/fr-FR/e8fccfc0-10e4-44bf-97d4-601b22908835/rotate-image-image-at-25-degree-using-vbnet-2008? forum = vbgeneral) – Hadi

+1

Copie possible de [Rotation d'une image dans une boîte d'image] (https://stackoverflow.com/questions/40431154/rotating-an-image-in-a-picture-box) –

Répondre

-1

Ma solution:

Public Function RotateImage(ByRef image As Image, ByVal offset As PointF, ByVal angle As Decimal) As Bitmap 
    If image Is Nothing Then 
     Throw New ArgumentNullException("image") 
    End If 
    ''create a new empty bitmap to hold rotated image 
    Dim rotatedBmp As Bitmap = New Bitmap(image.Width, image.Height) 
    'Dim rotatedBmp As Bitmap = New Bitmap(image) 
    rotatedBmp.SetResolution(image.HorizontalResolution, image.VerticalResolution) 
    ''make a graphics object from the empty bitmap 
    Dim g As Graphics = Graphics.FromImage(rotatedBmp) 
    ''Put the rotation point in the center of the image 
    g.TranslateTransform(offset.X, offset.Y) 
    ''rotate the image 
    g.RotateTransform(angle) 
    ''move the image back 
    g.TranslateTransform(-offset.X, -offset.Y) 
    ''draw passed in image onto graphics object 
    'g.DrawImage(image, New PointF(0, 0)) 
    g.DrawImage(image, offset) 
    Return rotatedBmp 
End Function 
+2

Comment cette gore de formatage peut-elle aider quelqu'un? Veuillez formater votre réponse et ajouter quelques mots épxplanationaux. Merci. – Clijsters