blob: 0c92ba57a7e97147c467a662c03e64235711580e (
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
35
36
37
38
39
40
41
|
/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using System.IO;
using PrusaSL1Reader;
using SixLabors.ImageSharp;
namespace PrusaSL1Viewer
{
public static class ImageSharpExtensions
{
public static System.Drawing.Bitmap ToBitmap(this Image image)
{
using (var memoryStream = new MemoryStream())
{
//var imageEncoder = image.GetConfiguration().ImageFormatsManager.FindEncoder(SixLabors.ImageSharp.Formats.Bmp.BmpFormat.Instance);
image.Save(memoryStream, Helpers.BmpEncoder);
//memoryStream.Seek(0, SeekOrigin.Begin);
return new System.Drawing.Bitmap(memoryStream);
}
}
/*public static Image<TPixel> ToImageSharpImage<TPixel>(this System.Drawing.Bitmap bitmap) where TPixel : struct, IPixel<TPixel>
{
using (var memoryStream = new MemoryStream())
{
bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
memoryStream.Seek(0, SeekOrigin.Begin);
return Image.Load<TPixel>(memoryStream);
}
}*/
}
}
|