Imageresizer tweaks

This commit is contained in:
TheXamlGuy
2024-07-03 10:57:28 +01:00
parent 8270bda787
commit 0a574ac5bb
+4 -6
View File
@@ -31,12 +31,10 @@ public class ImageResizer :
int cropY = (resized.Height - targetHeight) / 2;
cropped = new SKBitmap(targetWidth, targetHeight);
using (SKCanvas croppedCanvas = new(cropped))
{
SKRect srcRect = new(cropX, cropY, cropX + targetWidth, cropY + targetHeight);
SKRect destRect = new(0, 0, targetWidth, targetHeight);
croppedCanvas.DrawBitmap(resized, srcRect, destRect);
}
using SKCanvas croppedCanvas = new(cropped);
SKRect originalRect = new(cropX, cropY, cropX + targetWidth, cropY + targetHeight);
SKRect targetRect = new(0, 0, targetWidth, targetHeight);
croppedCanvas.DrawBitmap(resized, originalRect, targetRect);
}
using SKImage image = SKImage.FromBitmap(cropped);