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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:51:53+00:00 2026-06-15T15:51:53+00:00

I am drawing at dc (DrawingContext) of a Grid like this: dc.DrawImage(_imageSource, new Rect(x,

  • 0

I am drawing at dc (DrawingContext) of a Grid like this:

dc.DrawImage(_imageSource, new Rect(x, y, width, height);

But, what if I wanted to rotate the image I am drawing on drawing context?

I know I can push effect to drawing context, but, it will affect all the drawings, while I want to rotate only drawing of _imageSource.

Any idea?

  • 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-06-15T15:51:55+00:00Added an answer on June 15, 2026 at 3:51 pm

    You could push a RotateTransform before drawing the image, and immediately pop the transform after drawing.

    var transform = new RotateTransform(...);
    dc.PushTransform(transform);
    dc.DrawImage(_imageSource, new Rect(x, y, width, height));
    dc.Pop();
    

    Alternatively you could create an ImageDrawing, add it to a DrawingGroup (which has a Transform property), and then draw the DrawingGroup:

    var drawingGroup = new DrawingGroup();
    drawingGroup.Transform = new RotateTransform(...);
    drawingGroup.Children.Add(new ImageDrawing(_imageSource, new Rect(x, y, width, height)));
    dc.DrawDrawing(drawingGroup);
    

    All the DrawingContext.Draw… methods actually create and draw the appropriate Drawing objects.


    Instead of continuously redrawing everything in an overridden OnRender() method you could also do the following:

    • Create a DrawingVisual as a container for your drawings. See Using DrawingVisual Objects about how to do that.

    • Create a DrawingGroup with an ImageDrawing as shown above and draw the DrawingGroup once into the DrawingContext provided by DrawingVisual.RenderOpen.

    • Use a MatrixTransform or a TransformGroup for the complete image transformation, i.e. translation and rotation. Set the DrawingGroup.Transform property to this transform (instead of RotateTransform only as shown above).

    • When an image’s position or rotation angle changes, only change the related transform. Redrawing is not necessary.

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

Sidebar

Related Questions

I'm drawing a graph in a WPF application, but lines drawn using drawingContext.DrawLine(...) are
Drawing a blank on this, and google was not helpful. Want to make a
This drawing shows a tree of parent-child relationships. It is directed, without cycles. A
I have the following drawing code: [[NSColor redColor] set]; NSRect fillRect = NSMakeRect(bounds.size.width -
I'm drawing a 3d scene in 5-6 drawcalls, but I have about 60000-65000 triangles
I am doing some custom drawing using DrawingContext in WPF. I am using DrawingContext.DrawText
I'm drawing a chart by direct calls to DrawLine on the DrawingContext . Since
I've got this in my CALayer drawing code - (void) drawInContext:(CGContextRef)ctx { self.frame =
Drawing bifurcation diagram for 1D system is clear but if I have 2D system
Drawing flat waves is easy, but I want to draw the wave between two

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.