SixLabors / ImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET
https://sixlabors.com/products/imagesharp/
Other
7.34k stars 847 forks source link

SetDrawingTransform doesn't seem to affect all Draw calls #2622

Closed RobotGizmo closed 9 months ago

RobotGizmo commented 9 months ago

Prerequisites

ImageSharp version

3.1.1

Other ImageSharp packages and versions

Drawing: 2.1.0

Environment (Operating system, version and so on)

Windows 11

.NET Framework version

.NET 8

Description

If I call SetDrawingTransform to set a rotation then call DrawImage the image isn't drawn with any rotation. Should SetDrawingTransform be affecting all draw calls or is it limited to only some of them?

Steps to Reproduce

This is basically the code, I just set the rotation on context then call DrawImage.

x.SetDrawingTransform(Matrix3x2Extensions.CreateRotationDegrees(60, new PointF(10, 10)));
x.DrawImage(bitmap); 

Images

No response

RobotGizmo commented 9 months ago

As a follow-up, I'm not sure if DrawImage counts as a shape or not. Sorry if this is a non-issue. If this is a non-issue is there a way to perform actions on an image when using DrawImage? Like can I tint the colour, scale it into a target rect, rotate it... etc without having to clone the original image, modify it, then dispose the clone?

JimBobSquarePants commented 9 months ago

DrawImage is a member of ImageSharp SetDrawingTransform. Is a member of ImageSharp.Drawing. That’s two separate libraries.

If you want to use the transform use ImageBrush.

This would have been better framed as a question in our Discussions channels.