How to Rotate an Image Using Matrix Class in Vb.Net

104 49
    • 1). Open the Visual Studio.NET IDE. Then open the Visual Basic project in which you want to implement the Matrix Class.

    • 2). Insert the following example code into the project:

      Public Sub RotateExample(ByVal e As PaintEventArgs)

      Dim myPen As New Pen(Color.Blue, 1)

      Dim myPen2 As New Pen(Color.Red, 1)

      e.Graphics.DrawRectangle(myPen, 150, 50, 200, 100)

      Dim myMatrix As New Matrix

      myMatrix.Rotate(45, MatrixOrder.Append)

      e.Graphics.Transform = myMatrix

      e.Graphics.DrawRectangle(myPen2, 150, 50, 200, 100)

      End Sub

      Modify the variables, methods and values according to the specification of your project.

    • 3). Test the project and confirm the code implementation is functioning. Save the project.

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.