Results 1 to 3 of 3

Thread: GDI Matrix transformations

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2008
    Location
    East Kent, UK
    Posts
    34

    GDI Matrix transformations

    I am drawing on the screen with Y direction as up the screen, rather than down, using the following code :-

    Code:
        Private mYFlip As New Matrix(1, 0, 0, -1, 0, 0)
    
        With e.Graphics
          .PageUnit = GraphicsUnit.Millimeter
          .Transform = mYFlip
    
          'drawing happens here
        End With
    I now need to translate the origin, scale the transformation, move the origin slightly - and then change the Y direction to be down the screen. It's the last part I am stuck on - I can read the current matrix, but how do I now create a new matrix, with Y down, based on the current matrix and associated origin and scale?

    Code:
        With e.Graphics
          .PageUnit = GraphicsUnit.Millimeter
          .Transform = mYFlip
    
          .TranslateTransform(whatX, whatY)
          .ScaleTransform(2.5, 2.5)
          .TranslateTransform(-125, -150)
    
          Dim mCurrentMatrix As Matrix = eg.Transform
          'what to do now, to keep origin and scale the same, but make Y down the screen?
    
          'drawing happens here
        End With
    Thank you in advance!

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: GDI Matrix transformations

    Your matrix myFlip already has the right values for Y-flipping. You can use Graphics.Transform to get the present transformation as well as to set it. I haven't checked it but that means you could apply myFlip to the present transformation like this:

    Code:
    .Transform.Multiply(myFlip)
    instead of your present line Dim mCurrentMatrix... etc.

    BB

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2008
    Location
    East Kent, UK
    Posts
    34

    Re: GDI Matrix transformations

    Thanks boops, I'll give that a try

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width