private void exportFramesToolStripMenuItem_Click(object sender, EventArgs e) { if (TexAnim == null) { return; } var f = Tools.FileIO.SaveFile(ApplicationSettings.ImageFileFilter); if (f != null) { for (int i = 0; i < TexAnim.ImageCount; i++) { var v = TexAnim.ImageBuffers.Array[i]; HSD_TlutBuffer pal = null; if (TexAnim.TlutBuffers != null) { pal = TexAnim.TlutBuffers.Array[i]; } HSD_TOBJ tobj = new HSD_TOBJ(); tobj.ImageData = v.Data; if (pal != null) { tobj.TlutData = pal.Data; } var frame = Tools.BitmapTools.BGRAToBitmap(tobj.GetDecodedImageData(), v.Data.Width, v.Data.Height); frame.Save(Path.GetDirectoryName(f) + "\\" + Path.GetFileNameWithoutExtension(f) + "_" + i.ToString() + Path.GetExtension(f)); frame.Dispose(); } } }
/// <summary> /// /// </summary> /// <param name=""></param> private void SetTOBJs(HSD_TOBJ[] tobjs) { if (TOBJ != null) { TOBJ._s.References.Clear(); foreach (var r in tobjs[0]._s.References) { TOBJ._s.References.Add(r.Key, r.Value); } TOBJ._s.SetData(tobjs[0]._s.GetData()); } if (TexAnim != null) { var imgs = new List <HSD_TexBuffer>(); var pals = new List <HSD_TlutBuffer>(); foreach (var tobj in tobjs) { HSD_TexBuffer buf = new HSD_TexBuffer(); buf.Data = tobj.ImageData; imgs.Add(buf); if (ImageDataFormat.IsPalettedFormat(tobj.ImageData.Format)) { HSD_TlutBuffer palbuf = new HSD_TlutBuffer(); palbuf.Data = tobj.TlutData; pals.Add(palbuf); } } // convert tobjs into proper strip var ib = new HSDArrayAccessor <HSD_TexBuffer>(); ib.Array = imgs.ToArray(); TexAnim.ImageBuffers = ib; if (tobjs.Length > 0 && ImageDataFormat.IsPalettedFormat(tobjs[0].ImageData.Format)) { var tb = new HSDRaw.HSDArrayAccessor <HSD_TlutBuffer>(); tb.Array = pals.ToArray(); TexAnim.TlutBuffers = tb; } else { TexAnim.TlutBuffers = null; } } if (TEXG != null) { TEXG.SetFromTOBJs(tobjs); Node.Refresh(); } }
/// <summary> /// /// </summary> /// <returns></returns> private HSD_TOBJ[] GetTOBJs() { HSD_TOBJ[] tobjs = new HSD_TOBJ[TextureCount]; if (TOBJ != null) { tobjs[0] = TOBJ; } if (TexAnim != null) { for (int i = 0; i < TexAnim.ImageCount; i++) { var v = TexAnim.ImageBuffers.Array[i]; HSD_TlutBuffer pal = null; if (TexAnim.TlutBuffers != null) { pal = TexAnim.TlutBuffers.Array[i]; } HSD_TOBJ tobj = new HSD_TOBJ(); tobj.ImageData = v.Data; if (pal != null) { tobj.TlutData = pal.Data; } tobjs[i] = tobj; } } if (TEXG != null) { tobjs = TEXG.ConvertToTOBJs(); } return(tobjs); }
private void importFramesToolStripMenuItem_Click(object sender, EventArgs e) { if (TexAnim == null) { return; } var files = Tools.FileIO.OpenFiles(ApplicationSettings.ImageFileFilter); if (files != null) { using (TextureImportDialog td = new TextureImportDialog()) { if (td.ShowDialog() == DialogResult.OK) { var matched = new HashSet <int>(); var tobjs = new List <HSD_TexBuffer>(); var pals = new List <HSD_TlutBuffer>(); foreach (var f in files) { int num = 0; int.TryParse(Regex.Match(Path.GetFileName(f).ToLower(), @"(?<=.*_)(\d+?)(?=\.)").Name, out num); Console.WriteLine(num + " " + Regex.Match(Path.GetFileName(f).ToLower(), @"(?<=.*_)(\d+?)(?=\.)").Groups[0].Value); if (!int.TryParse(Regex.Match(Path.GetFileName(f).ToLower(), @"(?<=.*_)(\d+?)(?=\.)").Groups[0].Value, out num) || matched.Contains(num)) { throw new InvalidDataException(num + " " + Path.GetFileName(f) + " is missing index tag or has duplicate index"); } else { HSD_TOBJ temp = new HSD_TOBJ(); TOBJConverter.InjectBitmap(f, temp, td.TextureFormat, td.PaletteFormat); HSD_TexBuffer buf = new HSD_TexBuffer(); buf.Data = temp.ImageData; tobjs.Add(buf); if (ImageDataFormat.IsPalettedFormat(td.TextureFormat)) { HSD_TlutBuffer palbuf = new HSD_TlutBuffer(); palbuf.Data = temp.TlutData; pals.Add(palbuf); } matched.Add(num); } } // convert tobjs into proper strip var ib = new HSDArrayAccessor <HSD_TexBuffer>(); ib.Array = tobjs.ToArray(); TexAnim.ImageBuffers = ib; if (ImageDataFormat.IsPalettedFormat(td.TextureFormat)) { var tb = new HSDRaw.HSDArrayAccessor <HSD_TlutBuffer>(); tb.Array = pals.ToArray(); TexAnim.TlutBuffers = tb; if (TexAnim?.AnimationObject?.FObjDesc?.List.Count < 2) { TexAnim.AnimationObject.FObjDesc.Next = new HSD_FOBJDesc(); TexAnim.AnimationObject.FObjDesc.Next.FromFOBJ(new HSD_FOBJ() { JointTrackType = JointTrackType.HSD_A_J_SCAX, Buffer = new byte[0] }); } } else { TexAnim.TlutBuffers = null; if (TexAnim?.AnimationObject?.FObjDesc?.List.Count > 1) { TexAnim.AnimationObject.FObjDesc.Next = null; } } Node = Node; } } } }
/// <summary> /// /// </summary> /// <param name=""></param> private void SetTOBJs(HSD_TOBJ[] tobjs) { if (TOBJ != null) { TOBJ = tobjs[0]; } if (TexAnim != null) { var imgs = new List <HSD_TexBuffer>(); var pals = new List <HSD_TlutBuffer>(); foreach (var tobj in tobjs) { HSD_TexBuffer buf = new HSD_TexBuffer(); buf.Data = tobj.ImageData; imgs.Add(buf); if (TPLConv.IsPalettedFormat(tobj.ImageData.Format)) { HSD_TlutBuffer palbuf = new HSD_TlutBuffer(); palbuf.Data = tobj.TlutData; pals.Add(palbuf); } } // convert tobjs into proper strip var ib = new HSDArrayAccessor <HSD_TexBuffer>(); ib.Array = imgs.ToArray(); TexAnim.ImageBuffers = ib; if (tobjs.Length > 0 && TPLConv.IsPalettedFormat(tobjs[0].ImageData.Format)) { var tb = new HSDRaw.HSDArrayAccessor <HSD_TlutBuffer>(); tb.Array = pals.ToArray(); TexAnim.TlutBuffers = tb; if (TexAnim?.AnimationObject?.FObjDesc?.List.Count < 2) { TexAnim.AnimationObject.FObjDesc.Next = new HSD_FOBJDesc(); TexAnim.AnimationObject.FObjDesc.Next.FromFOBJ(new HSD_FOBJ() { AnimationType = JointTrackType.HSD_A_J_SCAX, Buffer = new byte[0] }); } } else { TexAnim.TlutBuffers = null; if (TexAnim?.AnimationObject?.FObjDesc?.List.Count > 1) { TexAnim.AnimationObject.FObjDesc.Next = null; } } } if (TEXG != null) { TEXG.SetFromTOBJs(tobjs); } }