Browse Source

Tweaking the center calculation abit

Former-commit-id: 1c29005edce7d8ddf809c1a11cc491beaf90e7eb
af/merge-core
perploug 12 years ago
parent
commit
df5c95cdb8
  1. 16
      src/ImageProcessor/Processors/Resize.cs

16
src/ImageProcessor/Processors/Resize.cs

@ -297,11 +297,13 @@ namespace ImageProcessor.Processors
if (centerCoordinates.Any()) if (centerCoordinates.Any())
{ {
destinationY = (int)((centerCoordinates[0] * sourceHeight) * ratio) - (height / 2); var center = -(ratio * sourceHeight) * centerCoordinates[0];
if (destinationY < 0) destinationY = (int)center + (height / 2);
if (destinationY > 0)
destinationY = 0; destinationY = 0;
if (destinationY + height > (sourceHeight * ratio)) if (destinationY < (int)(height - (sourceHeight * ratio)))
destinationY = (int)(height - (sourceHeight * ratio)); destinationY = (int)(height - (sourceHeight * ratio));
} }
else else
@ -328,11 +330,13 @@ namespace ImageProcessor.Processors
if (centerCoordinates.Any()) if (centerCoordinates.Any())
{ {
destinationX = (int)((centerCoordinates[1] * sourceWidth) * ratio) - (width / 2); var center = -(ratio * sourceWidth) * centerCoordinates[1];
if (destinationX < 0) destinationX = (int)center + (width / 2);
if (destinationX > 0)
destinationX = 0; destinationX = 0;
if (destinationX + width > (sourceWidth * ratio)) if (destinationX < (int)(width - (sourceWidth * ratio)))
destinationX = (int)(width - (sourceWidth * ratio)); destinationX = (int)(width - (sourceWidth * ratio));
} }
else else

Loading…
Cancel
Save