Results 1 to 6 of 6

Thread: Flip Rectangle

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Location
    India
    Posts
    318

    Flip Rectangle

    Hi,

    Could anyone tell me how to flip rectangles in picturebox?

    Thanks

  2. #2

    Re: Flip Rectangle

    I'm pretty sure the Graphics class has the ability to Transform images.

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

    Re: Flip Rectangle

    Quote Originally Posted by shersu View Post
    Hi,

    Could anyone tell me how to flip rectangles in picturebox?

    Thanks
    Use Image.RotateFlip. For example,

    Code:
    PictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipX)
    PictureBox1.Invalidate()
    Edit: Maybe I misread your question. If you are drawing the rectangles in the Paint event rather than setting the PictureBox.Image, then you need to go the way FormlessTree suggested. You can use a Matrix object with values (-1, -0, 0, 1, 0, 0) to flip the graphics horizontally or (1, 0, 0, -1, 0, 0) to do it vertically. See my reply in this thread post #9 for an example of using the matrix. BB

    BB

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Location
    India
    Posts
    318

    Re: Flip Rectangle

    Here's my code so far:

    Dim g As Graphics = pb.CreateGraphics()
    Dim x As Integer = CInt(CurrentRecord(4))
    Dim y As Integer = CInt(CurrentRecord(6))
    Dim width As Integer = CInt(CurrentRecord(5))
    Dim height As Integer = CInt(CurrentRecord(7))
    Dim rect As New Rectangle(x, y, width, height)
    Dim redPen As New Pen(Color.Black, 2)
    g.DrawRectangle(redPen, rect)
    Dim mtx As New Matrix
    redPen.Dispose()
    g.Dispose()

    I want to flip the rectangle upside down.

    Thanks

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: Flip Rectangle

    Flip the rectangle upside down? Rectangles have bilateral symmetry, a solid rectangle flipped upside down looks exactly the same as it did before the flip. You could rotate your rectangle by some degree, but flipping it upside down wouldn't do anything.
    My usual boring signature: Nothing

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Location
    India
    Posts
    318

    Re: Flip Rectangle

    Well, it's a cluster of rectangles placed in a particular order. That looks upside down. That's why I want to flip it.

    Thanks

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