Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ResizedImage(const AImage: ISkImage; const ANewWidth, ANewHeight: Integer; const Proportional: Boolean = True): ISkImage;
- var
- LSurface: ISkSurface;
- HScale, VScale: Single;
- begin
- HScale := ANewWidth / AImage.Width;
- VScale := ANewHeight / AImage.Height;
- if Proportional then
- begin
- HScale := min(HScale, VScale);
- VScale := HScale;
- end;
- LSurface := TSkSurface.MakeRaster(ANewWidth, ANewHeight);
- LSurface.Canvas.Clear(TAlphaColors.Null);
- LSurface.Canvas.Scale(HScale, VScale);
- LSurface.Canvas.DrawImage(AImage, 0, 0, TSkSamplingOptions.High);
- Result := LSurface.MakeImageSnapshot;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement