public ObfTxfListEntry(ObfTxfList parent, EndianBinaryReader reader) { Parent = parent; Offset = reader.BaseStream.Position; Unknown0x00 = reader.ReadUInt32(); TxfData = new Txf(reader); }
public void GenerateBitmap(Txf txf) { //ImageReferenceData imgref = ParentInfoBlock.ImageReferences[ImageNumber]; // wrong? index out of range sometimes? also not used yet b/c i don't know how that thing works ImageInformation imageInfos = txf.GetImageInformation(txf.PixelDataHeaders[ImageNumber], txf.PaletteDataHeaders[PaletteNumber]); if (imageInfos == null || Rectangle.Width == 0 || Rectangle.Height == 0) { Image = new Bitmap(4, 4); return; } Image = new Bitmap(Rectangle.Width, Rectangle.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(Image)) { g.DrawImage(imageInfos.Bitmap, new Rectangle(0, 0, Image.Width, Image.Height), Rectangle, GraphicsUnit.Pixel); } }
public AnmDat(string filePath) : base(filePath) { using (EndianBinaryReader reader = new EndianBinaryReader(File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Endian.BigEndian)) { InfoBlockSize = reader.ReadUInt32(); ImageDataSize = reader.ReadUInt32(); NumPixelDataHeaders = reader.ReadUInt32(); NumPaletteDataHeaders = reader.ReadUInt32(); NumInfoBlocks = reader.ReadUInt32(); Unknown0x14 = reader.ReadUInt32(); Unknown0x18 = reader.ReadUInt32(); Unknown0x1C = reader.ReadUInt32(); InfoBlocks = new InfoBlockData[NumInfoBlocks]; for (int i = 0; i < InfoBlocks.Length; i++) { long offset = reader.BaseStream.Position; InfoBlocks[i] = new InfoBlockData(this, reader); reader.BaseStream.Seek(offset + InfoBlocks[i].InfoEntrySize, SeekOrigin.Begin); } TxfData = new Txf(reader, (int)ImageDataSize, (int)NumPixelDataHeaders, (int)NumPaletteDataHeaders); foreach (InfoBlockData infoBlock in InfoBlocks) { /* Post-processing */ foreach (AnimationData animation in infoBlock.Animations.Where(x => x != null)) { animation.FirstNode = infoBlock.AnimationNodes[animation.FirstNodeID]; } foreach (AnimationFrameData animationFrame in infoBlock.AnimationFrames.Where(x => x != null)) { animationFrame.Sprite = infoBlock.Sprites[animationFrame.SpriteID]; animationFrame.Transform = infoBlock.Transforms[animationFrame.TransformID]; } foreach (SpriteData sprite in infoBlock.Sprites.Where(x => x != null)) { sprite.GenerateBitmap(TxfData); } foreach (TransformData transform in infoBlock.Transforms.Where(x => x != null)) { transform.TransformOffset = infoBlock.TransformOffsets[transform.TransformOffsetID]; } foreach (AnimationNodeData animationNode in infoBlock.AnimationNodes.Where(x => x != null)) { if (animationNode.FirstAnimationFrameID != -1) { animationNode.AnimationFrames = new AnimationFrameData[animationNode.NumAnimationFrames]; for (int i = 0; i < animationNode.AnimationFrames.Length; i++) { animationNode.AnimationFrames[i] = infoBlock.AnimationFrames[animationNode.FirstAnimationFrameID + i]; } } if (animationNode.SiblingNodeID != -1) { animationNode.SiblingNode = infoBlock.AnimationNodes[animationNode.SiblingNodeID]; } if (animationNode.ChildNodeID != -1) { animationNode.ChildNode = infoBlock.AnimationNodes[animationNode.ChildNodeID]; } } } } }