Skip to content

How to properly handle situation when you need to rotate an image, drawImage() another image in that rectangle, then rotate the image back? #2726

Answered by tocsoft
MissedSte4k asked this question in Q&A
Discussion options

You must be logged in to vote

Sample has been updated with rotation support

relevant code you will need to generate each region of interest to combine is this.

...
public IPath AsPath()
    => new RectangularPolygon(Rect.X, Rect.Y, Rect.Width, Rect.Height)
        .Transform(
            Matrix3x2Extensions.CreateRotationDegrees(
                Rotation,
                new PointF((Rect.Width / 2 + Rect.X), (Rect.Height / 2 + Rect.Y))
            )
        );
...

https://github.com/SixLabors/Samples/blob/67ffd43bf3dae46a659fa4deb9eaa23af6ca7302/ImageSharp/BlurMultiplePartsOfImage/Program.cs#L25-L32

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@MissedSte4k
Comment options

Comment options

You must be logged in to vote
4 replies
@MissedSte4k
Comment options

@tocsoft
Comment options

@tocsoft
Comment options

Answer selected by MissedSte4k
@MissedSte4k
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants