Rotate without moving. #1270
-
Hi all! I have a 410x410 image (lets call it the wheel) that I want to overlay onto another 500x800 image (lets call this the background). I want the wheel to be at 250,250 on the background, and to be able to rotate it freely. The issue is when rotating, it seems the bounding box gets resized - causing what is considered to be the 0, 0 point of the wheel to be moved. Is there any way around this? For example, if I rotate the wheel 45 degrees, the bounding box gets bigger as what would be the top left corner moves to where the 'centre' would be, right at the top - pushing the height of the image up, and the same with the width. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
this is my current workaround; which feels very hacky. wheel.Mutate(context =>
{
context.Rotate(22.5f);
var size = context.GetCurrentSize();
var middleX = size.Width / 2;
var middleY = size.Height / 2;
context.Crop(new Rectangle(middleX - 205, middleY - 205, 410, 410));
}); |
Beta Was this translation helpful? Give feedback.
-
Well yes, that's maths. Unless you want to clip your input your dimensions will be equal to the hypotenuse of the two sides. Most rotations want to preserve the original input without clipping so we've built our rotation with that behavior since, as you've demonstrated it's fairly simple to crop the image following a rotation. |
Beta Was this translation helpful? Give feedback.
Well yes, that's maths. Unless you want to clip your input your dimensions will be equal to the hypotenuse of the two sides.
Most rotations want to preserve the original input without clipping so we've built our rotation with that behavior since, as you've demonstrated it's fairly simple to crop the image following a rotation.