Hi,
Could anyone tell me how to flip rectangles in picturebox?
Thanks
Printable View
Hi,
Could anyone tell me how to flip rectangles in picturebox?
Thanks
I'm pretty sure the Graphics class has the ability to Transform images.
Use Image.RotateFlip. For example,
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. BBCode:PictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipX)
PictureBox1.Invalidate()
BB
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
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.
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