From 6b14bc71cb699b72ca6cf164b7b800add414dec6 Mon Sep 17 00:00:00 2001 From: Treeki Date: Mon, 28 Feb 2011 03:23:02 +0100 Subject: progress on writing: offset calculation for models and textures complete! --- NW4RTools/Texture.cs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'NW4RTools/Texture.cs') diff --git a/NW4RTools/Texture.cs b/NW4RTools/Texture.cs index 7063056..0561435 100644 --- a/NW4RTools/Texture.cs +++ b/NW4RTools/Texture.cs @@ -64,10 +64,9 @@ namespace NW4RTools { - public Bitmap BaseImage; + public Bitmap[] Images; public TextureFormat Format; - public UInt32 MipMapCount; public float MinLOD, MaxLOD; public Texture() { @@ -82,11 +81,26 @@ namespace NW4RTools { // align width, height up width = Misc.AlignUp(width, info.TexelWidth); height = Misc.AlignUp(height, info.TexelHeight); - + + // SPECIAL CASE: + return width * height * info.NybblesPerPixel / 2; } - unsafe public void ImportData(byte[] imgdata, int width, int height, TextureFormat format) { + + public int GetDataSize() { + int size = 0; + for (int i = 0; i < Images.Length; i++) { + size += GetDataSize(i); + } + return size; + } + + public int GetDataSize(int imageID) { + return GetDataSize(Images[imageID].Width, Images[imageID].Height, Format); + } + + unsafe public void ImportData(int imageID, byte[] imgdata, int width, int height, TextureFormat format) { var image = new Bitmap(width, height, PixelFormat.Format32bppArgb); var bits = image.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, image.PixelFormat); @@ -274,7 +288,7 @@ namespace NW4RTools { image.UnlockBits(bits); - BaseImage = image; + Images[imageID] = image; Format = format; } -- cgit v1.2.3