-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.m
28 lines (18 loc) · 976 Bytes
/
readme.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
This project is Image Resizer for Linux machins.
This project is used from SkiaSharp library and SkiaSharp.NativeAssets.Linux library.
public static void ResizeImage(Stream fileContents,
int maxWidth, int maxHeight, string saveFilePath,
SKFilterQuality quality = SKFilterQuality.Medium)
{
fileContents.Seek(0, SeekOrigin.Begin);
using SKBitmap sourceBitmap = SKBitmap.Decode(fileContents);
using SKBitmap scaledBitmap = sourceBitmap.Resize(new SKImageInfo(maxWidth, maxHeight), quality);
using SKImage scaledImage = SKImage.FromBitmap(scaledBitmap);
using SKData data = scaledImage.Encode();
using (var fileStream = System.IO.File.Create(saveFilePath))
{
var myStream = data.AsStream();
myStream.Seek(0, SeekOrigin.Begin);
myStream.CopyTo(fileStream);
}
}