mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-18 03:24:15 -04:00
Don't use ImageSharp for texture processing
- returned to System.Drawing (ImageSharp is a good lib, but too slow for such app, IMO)
This commit is contained in:
@ -1,38 +1,31 @@
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Formats.Bmp;
|
||||
using SixLabors.ImageSharp.Formats.Tga;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using TGASharpLib;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public static class ImageExtensions
|
||||
{
|
||||
public static MemoryStream ConvertToStream(this Image image, ImageFormat imageFormat)
|
||||
public static MemoryStream ConvertToStream(this Bitmap image, ImageFormat imageFormat)
|
||||
{
|
||||
var outputStream = new MemoryStream();
|
||||
switch (imageFormat)
|
||||
{
|
||||
case ImageFormat.Jpeg:
|
||||
image.SaveAsJpeg(outputStream);
|
||||
image.Save(outputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||
break;
|
||||
case ImageFormat.Png:
|
||||
image.SaveAsPng(outputStream);
|
||||
image.Save(outputStream, System.Drawing.Imaging.ImageFormat.Png);
|
||||
break;
|
||||
case ImageFormat.Bmp:
|
||||
image.Save(outputStream, new BmpEncoder
|
||||
{
|
||||
BitsPerPixel = BmpBitsPerPixel.Pixel32,
|
||||
SupportTransparency = true
|
||||
});
|
||||
image.Save(outputStream, System.Drawing.Imaging.ImageFormat.Bmp);
|
||||
break;
|
||||
case ImageFormat.Tga:
|
||||
image.Save(outputStream, new TgaEncoder
|
||||
{
|
||||
BitsPerPixel = TgaBitsPerPixel.Pixel32,
|
||||
Compression = TgaCompression.None
|
||||
});
|
||||
var tga = new TGA(image);
|
||||
tga.Save(outputStream);
|
||||
break;
|
||||
}
|
||||
image.Dispose();
|
||||
return outputStream;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user