public static TplTextureWrapper Create(TPL tpl, TPL_IO.Header header, string FileName) { TplTextureWrapper tex = new TplTextureWrapper(tpl); tex.Replace(FileName); if (tex.ImageData == null) //Dialog cancelled if image data not set { return(null); } tex.ImageHeader.Width = (ushort)tex.Width; tex.ImageHeader.Height = (ushort)tex.Height; tex.ImageHeader.Format = Decode_Gamecube.FromGenericFormat(tex.Format); tex.ImageHeader.MaxLOD = (byte)tex.MipCount; header.Images.Add(new TPL_IO.ImageEntry() { Header = tex.ImageHeader, ImageData = tex.ImageData, PaletteHeader = tex.PaletteHeader, }); return(tex); }
public void Load(System.IO.Stream stream) { Text = FileName; CanSave = true; using (var reader = new FileReader(stream)) { reader.SetByteOrder(true); Header = new TPL_IO.Header(); Header.Read(reader); foreach (var tex in Header.Images) { var texWrapper = new TplTextureWrapper(this, tex.Header); texWrapper.PaletteHeader = tex.PaletteHeader; texWrapper.ImageKey = "Texture"; texWrapper.SelectedImageKey = "Texture"; texWrapper.Format = Decode_Gamecube.ToGenericFormat(tex.Header.Format); texWrapper.Width = tex.Header.Width; texWrapper.Height = tex.Header.Height; texWrapper.ImageData = tex.ImageData; texWrapper.MipCount = tex.Header.MaxLOD; texWrapper.PlatformSwizzle = PlatformSwizzle.Platform_Gamecube; Nodes.Add(texWrapper); if (tex.PaletteHeader != null) { var GXPaletteFormat = (Decode_Gamecube.PaletteFormats)tex.PaletteHeader.PaletteFormat; texWrapper.SetPaletteData(tex.PaletteHeader.Data, Decode_Gamecube.ToGenericPaletteFormat(GXPaletteFormat)); } } UpdateDisplayedNames(); } }