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:
VaDiM
2026-03-13 13:27:47 +03:00
parent 94090a997a
commit 61d9bc8f15
16 changed files with 611 additions and 407 deletions
+28
View File
@@ -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;
}
}
});
}
}
}
}