blob: 2a2f38701dc663c6a0b1a9619f9c75a2eb6d08fe (
plain)
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
29
30
31
32
33
34
|
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats;
using System.IO;
namespace Timeline.Tests.Helpers
{
public static class ImageHelper
{
public static byte[] CreatePngWithSize(int width, int height)
{
using (var image = new Image<Rgba32>(width, height))
{
using (var stream = new MemoryStream())
{
image.SaveAsPng(stream);
return stream.ToArray();
}
}
}
public static byte[] CreateImageWithSize(int width, int height, IImageFormat format)
{
using (var image = new Image<Rgba32>(width, height))
{
using (var stream = new MemoryStream())
{
image.Save(stream, format);
return stream.ToArray();
}
}
}
}
}
|