public override void SetImageData(Bitmap bitmap, int ArrayLevel) { if (bitmap == null) { return; //Image is likely disposed and not needed to be applied } MipCount = GenerateMipCount(bitmap.Width, bitmap.Height); XTXFormat = ConvertFromGenericFormat(Format); var tex = new Syroot.NintenTools.NSW.Bntx.Texture(); tex.Height = (uint)bitmap.Height; tex.Width = (uint)bitmap.Width; tex.Format = TextureData.GenericToBntxSurfaceFormat(Format); tex.Name = Text; tex.Path = ""; tex.TextureData = new List <List <byte[]> >(); STChannelType[] channels = SetChannelsByFormat(Format); tex.sparseBinding = 0; //false tex.sparseResidency = 0; //false tex.Flags = 0; tex.Swizzle = 0; tex.textureLayout = 0; tex.Regs = new uint[0]; tex.AccessFlags = AccessFlags.Texture; tex.ArrayLength = (uint)ArrayLevel; tex.MipCount = MipCount; tex.Depth = Depth; tex.Dim = Syroot.NintenTools.NSW.Bntx.GFX.Dim.Dim2D; tex.TileMode = Syroot.NintenTools.NSW.Bntx.GFX.TileMode.Default; tex.textureLayout2 = 0x010007; tex.SurfaceDim = Syroot.NintenTools.NSW.Bntx.GFX.SurfaceDim.Dim2D; tex.SampleCount = 1; tex.Pitch = 32; tex.MipOffsets = new long[tex.MipCount]; var mipmaps = TextureImporterSettings.SwizzleSurfaceMipMaps(tex, GenerateMipsAndCompress(bitmap, MipCount, Format), MipCount); ImageData = Utils.CombineByteArray(mipmaps.ToArray()); }
public override void SetImageData(Bitmap bitmap, int ArrayLevel) { var tex = new Syroot.NintenTools.NSW.Bntx.Texture(); tex.Height = (uint)bitmap.Height; tex.Width = (uint)bitmap.Width; tex.Format = TextureData.GenericToBntxSurfaceFormat(Format); tex.Name = Text; tex.Path = ""; tex.TextureData = new List <List <byte[]> >(); STChannelType[] channels = SetChannelsByFormat(Format); tex.sparseBinding = 0; //false tex.sparseResidency = 0; //false tex.Flags = 0; tex.Swizzle = 0; tex.textureLayout = 0; tex.Regs = new uint[0]; tex.AccessFlags = AccessFlags.Texture; tex.ArrayLength = (uint)ArrayLevel; tex.MipCount = MipCount; tex.Depth = Depth; tex.Dim = Syroot.NintenTools.NSW.Bntx.GFX.Dim.Dim2D; tex.TileMode = Syroot.NintenTools.NSW.Bntx.GFX.TileMode.Default; tex.textureLayout2 = 0x010007; tex.SurfaceDim = Syroot.NintenTools.NSW.Bntx.GFX.SurfaceDim.Dim2D; tex.SampleCount = 1; tex.Pitch = 32; tex.MipOffsets = new long[tex.MipCount]; var mipmaps = TextureImporterSettings.SwizzleSurfaceMipMaps(tex, GenerateMipsAndCompress(bitmap, MipCount, Format), MipCount); ImageData = Utils.CombineByteArray(mipmaps.ToArray()); ArrayCount = tex.ArrayLength; TexFormat = FormatTable.FirstOrDefault(x => x.Value == Format).Key; UpdateProperties(); }