Browse Source

Zooms the image when doing an 'inside rotation'

Former-commit-id: cb58553b092c507ec2b0ec88628ee2f140f25bdf
Former-commit-id: d004bc57d5c645e5b95e75cf3f5890419e2a23e5
pull/17/head
Thomas Broust 11 years ago
parent
commit
1880dd84f8
  1. 7
      src/ImageProcessor/Processors/RotateInside.cs

7
src/ImageProcessor/Processors/RotateInside.cs

@ -83,7 +83,7 @@ namespace ImageProcessor.Processors
/// <param name="angle">The angle in degrees at which to rotate the image.</param>
/// <returns>The image rotated to the given angle at the given position.</returns>
/// <remarks>
/// Based on <see cref="T:ImageProcessor.Processors.Rotate"/>
/// Based on the Rotate effect
/// </remarks>
private Bitmap RotateImage(Image image, float rotateAtX, float rotateAtY, float angle)
{
@ -91,6 +91,8 @@ namespace ImageProcessor.Processors
Bitmap newImage = new Bitmap(image.Width, image.Height);
newImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
float zoom = Imaging.Rotation.ZoomAfterRotation(image.Width, image.Height, angle);
// Make a graphics object from the empty bitmap
using (Graphics graphics = Graphics.FromImage(newImage))
{
@ -106,6 +108,9 @@ namespace ImageProcessor.Processors
// Rotate the image
graphics.RotateTransform(angle);
// Zooms the image to fit the area
graphics.ScaleTransform(zoom, zoom);
// Move the image back
graphics.TranslateTransform(-rotateAtX * 2, -rotateAtY * 2);

Loading…
Cancel
Save