Browse Source

Zooms the image when doing an 'inside rotation'

Former-commit-id: 983fc19db77f6ddc5bdfca37b5151f891e103dfb
Former-commit-id: 14453bf615233062120f7e4f2cc11889a1df7778
pull/17/head
Thomas Broust 11 years ago
parent
commit
7d36e0a1e7
  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