Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6366505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:25:47+00:00 2026-05-25T00:25:47+00:00

I have a bitmap with a Rectangle object that is drawn on top of

  • 0

I have a bitmap with a Rectangle object that is drawn on top of it. I want to be able to RotateFlip the bitmap and adjust the x, y, width, and height of the Rectangle so that it lines up with the bitmap after each rotation or flip.

For example, if I have a bitmap of 1000 x 800 pixels, I may have a Rectangle object being drawn on it with a specified point and size.

Sample code:

// A bitmap that's 1000x800 size
Bitmap bitmap = new Bitmap(fileName); 

// Any arbitrary rectangle that can be drawn inside the bitmap boundaries
Rectangle rect = new Rectangle(200, 200, 100, 100);

bitmap.RotateFlip(rotateFlipType);

switch (rotateFlipType)
{
    case Rotate90FlipNone:
        // Adjust rectangle to match new bitmap orientation
        rect = new Rectangle(?, ?, ?, ?);
        break;
    case RotateNoneFlip180:
        rect = new Rectangle(?, ?, ?, ?);
        break;
    // ... etc.
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:25:48+00:00Added an answer on May 25, 2026 at 12:25 am

    I find it easiest to reason through each scenario by drawing a picture and labeling rect.Top, rect.Bottom, rect.Left, and rect.Right. Once that’s done, I either mentally rotate the picture, or even physically rotate the paper. From there, it’s as simple as figuring out where the new rect.Left and rect.Top live.

    A few general tips:

    • For 90 degree and 270 degree rotations, rect.Width and rect.Height have to be swapped.
    • It’s often easiest to compute the new top or the new left using bitmap.Width-rect.Right and bitmap.Height-rect.Bottom.

    Here are your two examples with the blanks filled in to get you started:

    switch (rotateFlipType)
    {
        case Rotate90FlipNone:
            // Adjust rectangle to match new bitmap orientation
            rect = new Rectangle(bitmap.Height-rect.Bottom, 
                                 rect.Left,
                                 rect.Height,
                                 rect.Width);
            break;
        case RotateNoneFlipHorizontally:
            rect = new Rectangle(bitmap.Width - rect.Right,
                                 rect.Top,
                                 rect.Width,
                                 rect.Height);
            break;
        // ... etc.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Bitmap that I want to enlarge programatically to ~1.5x or 2x
I have a BitmapData object created dynamically that contains user-drawn shapes. I then attach
I have a bitmap image context and want to let this appear blurry. So
I have a bitmap object and draw some curves on it by setpixel method.
I have a gdi+ bitmap, and I want to convert bitmap into HBitmap. I
I have a chart (in bitmap format) that I'm trying to render to a
I am creating a rectangle as a custom control object that is placed within
I have the following function: static private Image CropRotate(Image wholeImage, Rectangle cropArea) { Bitmap
I have been doing some unsafe bitmap operations and have found out that increasing
I have a C# app for which I've written GDI+ code that uses Bitmap/TextureBrush

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.