diff options
author | Treeki <treeki@gmail.com> | 2011-02-28 03:23:02 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-02-28 03:23:02 +0100 |
commit | 6b14bc71cb699b72ca6cf164b7b800add414dec6 (patch) | |
tree | 414bc20c8af5ae1373a4a15ddaaf2f706e3cb75f /NW4RTools/Texture.cs | |
parent | 00e977b3dbb8f447b034b7be387ee1a1cce0598c (diff) | |
download | nw4rtools-6b14bc71cb699b72ca6cf164b7b800add414dec6.tar.gz nw4rtools-6b14bc71cb699b72ca6cf164b7b800add414dec6.zip |
progress on writing: offset calculation for models and textures complete!
Diffstat (limited to 'NW4RTools/Texture.cs')
-rw-r--r-- | NW4RTools/Texture.cs | 24 |
1 files changed, 19 insertions, 5 deletions
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; } |