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 7412087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:29:12+00:00 2026-05-29T06:29:12+00:00

I have an application for drawing and editing vector graphics in WinForms I have

  • 0

I have an application for drawing and editing vector graphics in WinForms

I have images, rectangles, ellipses, regions etc. and I know how to resize them by mouse move. But I don’t know how to rotate them by mouse move.

I draw objects into Graphics.

I’ve tried this, but it didn’t work.

g.TranslateTransform((float)(this.Rectangle.X + this.Rectangle.Width / 2), (float)(this.Rectangle.Y + this.Rectangle.Height / 2));
g.RotateTransform(this.Rotation);
g.TranslateTransform(-(float)(this.Rectangle.X + this.Rectangle.Width / 2), -(float)(this.Rectangle.Y + this.Rectangle.Height / 2));
//g.TranslateTransform(-(float)(rect.X + rect.Width / 2), -(float)(rect.Y + rect.Height / 2));

g.DrawImage(img, rect);

g.ResetTransform();

This didn’t work, because I don’t know how to find corners of objects in new (rotated) position, so I’m not able to resize that…

  • 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-29T06:29:13+00:00Added an answer on May 29, 2026 at 6:29 am

    You need to apply high school trigonometry. There are lots of articles if you google “graphics.drawimage rotation”

    But to start with, you should NOT be transforming the Graphics object itself. You are just looking to get the new bounding box of your image. To do this:

    1. Take the bounding box of the image centered on the origin. Remember this is defined as three points for the benefit of DrawImage(Image, Point[])

      Point[] boundingBox = { new Point(-width /2, -height/2),
                              new Point(width/2, -height/2), 
                              new Point(-width/2, height/2) };
      
    2. Use trig to rotate it. Feed each point through the following function:

      Point rotatePointAroundOrigin(Point point, float angleInDegrees) {
          float angle = angleInDegrees * Math.PI/180; // get angle in radians
          return new Point( point.X * Math.Cos(angle) - point.Y * Math.Sin(angle),
                            point.X * Math.Sin(angle) + point.Y * Math.Cos(angle));
      }
      
    3. Translate the boundind box to where it has to go. Add the width/2 and height/2 to each of its points, plus whatever extra amount you want.

    4. Call DrawImage(image, boundingBox)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drawing application developed in winforms C# which uses many System.Drawing.Bitmap object
I have an application that writes text onto images using System.Drawing (C#). I am
I have developed application for drawing some shapes (lines mostly) , now i need
I'm writing a drawing application that includes shapes that can have children. When I
In my WPF application I have some drawing functionality. I have solved this using
In my WPF application I have a Canvas in which I do some drawing.
I have a somewhat complex data model in my iPad application (an OpenGL drawing
in a simple drawing application I have a model which has a NSMutableArray curvedPaths
Have a simple drawing application. The problem is in the coordinates ( redraw function):
I was looking at this vector drawing application called Creative Docs .Net . I

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.