CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 25

Thread: Flip Rectangle

  1. #1
    Join Date
    Apr 2004
    Posts
    265

    Flip Rectangle

    Hi,

    Could anyone tell me how to flip rectangles in picturebox?

    Thanks

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Flip Rectangle


  3. #3
    Join Date
    Apr 2004
    Posts
    265

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Flip Rectangle

    You would have to know the SCALE of the view
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Apr 2004
    Posts
    265

    Re: Flip Rectangle

    Scaling is all fine. I only have to turn it upside down.

    Thanks

  6. #6
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Flip Rectangle

    Didn't you read the link I sent you Shers? In there I cover Rotation and Flipping

  7. #7
    Join Date
    Apr 2004
    Posts
    265

    Re: Flip Rectangle

    Quote Originally Posted by HanneSThEGreaT View Post
    Didn't you read the link I sent you Shers? In there I cover Rotation and Flipping
    I went through the link and found that it's only for image rotation. My problem is rectangle flip vertical.

    I'm attaching an image. If I change the y in

    Dim rect As New Rectangle(x, y, width, height) to

    Dim rect As New Rectangle(x, -y, width, height), I still see no change in the image. I drew a line to see how it works, and it still is below the line

    Thanks
    Attached Images Attached Images  
    Last edited by shers; August 19th, 2011 at 04:25 AM.

  8. #8
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Flip Rectangle

    Firstly a recatangle no mater flipped which way will always look the same ... However if your trying to flip the image inside the rectangle the section titled Rotation on page two of Hanne's article is what your looking for... and you can use any of these options
    Last edited by GremlinSA; August 19th, 2011 at 05:33 AM.
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  9. #9
    Join Date
    Apr 2004
    Posts
    265

    Re: Flip Rectangle

    It is nothing concerning image. I'm only drawing rectangles. A looping through results in a cluster of small and big rectangles which looks in an orderly manner. I want the final result to be flipped vertical as a whole, or flip each rectangle while looping through. That's what I tried, but looks like there's no change, as I drew a line to see where it is placed, but how much ever change I do, it still is below the line.

    Thanks

  10. #10
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Flip Rectangle

    Ahhh ....

    You not Flipping anything.... All you want to do is shift the position of the rectangle ..

    Code:
    Dim Ycenter as integer = 0
    
    Dim rect As New Rectangle(x, Ycenter- (y + height), width, height)
    Now you can change Ycenter to where you want the 'Illusion' of the flip to take place...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  11. #11
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Flip Rectangle

    This why questions should be asked properly upfront, to avoid confusion

  12. #12
    Join Date
    Apr 2004
    Posts
    265

    Re: Flip Rectangle

    Quote Originally Posted by GremlinSA View Post
    Ahhh ....

    You not Flipping anything.... All you want to do is shift the position of the rectangle ..

    Code:
    Dim Ycenter as integer = 0
    
    Dim rect As New Rectangle(x, Ycenter- (y + height), width, height)
    Now you can change Ycenter to where you want the 'Illusion' of the flip to take place...
    WOW!!!! That's fantastic! I had been trying for soooo long to get to it. Thank you sooooo much!!

  13. #13
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Flip Rectangle

    Glad you came right.

    Quote Originally Posted by shers View Post
    WOW!!!! That's fantastic! I had been trying for soooo long to get to it. Thank you sooooo much!!
    Sometimes when we are struggling with something that seems so basic and simple, we tend to look for much more complex solutions, than what we really need. I guess it is the despondancy, or even desperateness creeping in. It happens

  14. #14
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Flip Rectangle

    Quote Originally Posted by shers View Post
    WOW!!!! That's fantastic! I had been trying for soooo long to get to it. Thank you sooooo much!!
    Sure no problem .. Just it would be so much easier if the question was asked properly the first time..

    Just glad we eventually worked it out...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  15. #15
    Join Date
    Apr 2004
    Posts
    265

    Re: Flip Rectangle

    Quote Originally Posted by GremlinSA View Post
    Sure no problem .. Just it would be so much easier if the question was asked properly the first time..
    I apologize for that.

    Is there any way I can crop the attached image to fit to the picturebox?

    Thanks

Page 1 of 2 12 LastLast

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

Featured