mirror of
https://github.com/aelurum/AssetStudio.git
synced 2026-11-14 11:18:47 -05:00
Add option to export images in "assetName@hash" name format
- Redesigned spriteHelper & texture2DConverter - Improved speed of texture2D preview a bit
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
using SixLabors.ImageSharp.Formats.Bmp;
|
||||
using SixLabors.ImageSharp.Formats.Tga;
|
||||
using SixLabors.ImageSharp.Formats.Webp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using System.IO;
|
||||
|
||||
namespace AssetStudio
|
||||
@@ -48,5 +50,31 @@ namespace AssetStudio
|
||||
image.WriteToStream(stream, imageFormat);
|
||||
return stream;
|
||||
}
|
||||
|
||||
public static void ApplyRgbMask(this Image<Bgra32> srcTex, Image<Bgra32> texMask, bool fastResize = false)
|
||||
{
|
||||
using (texMask)
|
||||
{
|
||||
if (srcTex.Width != texMask.Width || srcTex.Height != texMask.Height)
|
||||
{
|
||||
var resampler = fastResize ? KnownResamplers.NearestNeighbor : KnownResamplers.Bicubic;
|
||||
texMask.Mutate(x => x.Resize(srcTex.Width, srcTex.Height, resampler));
|
||||
}
|
||||
|
||||
srcTex.ProcessPixelRows(texMask, (sourceTex, targetTexMask) =>
|
||||
{
|
||||
for (var y = 0; y < texMask.Height; y++)
|
||||
{
|
||||
var texRow = sourceTex.GetRowSpan(y);
|
||||
var maskRow = targetTexMask.GetRowSpan(y);
|
||||
for (var x = 0; x < maskRow.Length; x++)
|
||||
{
|
||||
var grayscale = (byte)((maskRow[x].R + maskRow[x].G + maskRow[x].B) / 3);
|
||||
texRow[x].A = grayscale;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user