Imageresizer tweaks
This commit is contained in:
@@ -31,12 +31,10 @@ public class ImageResizer :
|
|||||||
int cropY = (resized.Height - targetHeight) / 2;
|
int cropY = (resized.Height - targetHeight) / 2;
|
||||||
|
|
||||||
cropped = new SKBitmap(targetWidth, targetHeight);
|
cropped = new SKBitmap(targetWidth, targetHeight);
|
||||||
using (SKCanvas croppedCanvas = new(cropped))
|
using SKCanvas croppedCanvas = new(cropped);
|
||||||
{
|
SKRect originalRect = new(cropX, cropY, cropX + targetWidth, cropY + targetHeight);
|
||||||
SKRect srcRect = new(cropX, cropY, cropX + targetWidth, cropY + targetHeight);
|
SKRect targetRect = new(0, 0, targetWidth, targetHeight);
|
||||||
SKRect destRect = new(0, 0, targetWidth, targetHeight);
|
croppedCanvas.DrawBitmap(resized, originalRect, targetRect);
|
||||||
croppedCanvas.DrawBitmap(resized, srcRect, destRect);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using SKImage image = SKImage.FromBitmap(cropped);
|
using SKImage image = SKImage.FromBitmap(cropped);
|
||||||
|
|||||||
Reference in New Issue
Block a user