public TextureFormat Import(MetadataReader metadata, string directory) { metadata.EnterSection("PE3DAT"); int count = metadata.GetAttribute <int>("Textures"); string basename = metadata.GetAttribute <string>("Basename"); uint[] positions1 = new uint[count]; ushort[] widths = new ushort[count]; ushort[] heights = new ushort[count]; uint[] positions2 = new uint[count]; int[] bpps = new int[count]; IList <Image> images = new List <Image>(count); for (int i = 0; i < count; i++) { metadata.EnterSection("PE3DATSegment"); positions1[i] = metadata.Get <uint>("Position1"); positions2[i] = metadata.Get <uint>("Position2"); bpps[i] = metadata.Get <int>("Bpp"); Image img = Image.FromFile(Path.Combine(directory, basename + "_" + i + ".png")); widths[i] = (ushort)img.Width; heights[i] = (ushort)img.Height; images.Add(img); metadata.ExitSection(); } metadata.ExitSection(); return(new PE3DATTexture(images, positions1, positions2, widths, heights, bpps)); }
public TextureFormat Import(MetadataReader metadata, string directory) { metadata.EnterSection("PE3SimpleDAT"); string basename = metadata.GetAttribute <string>("Basename"); byte[] rawHeader = metadata.Get <byte[]>("RawHeader"); Image img = Image.FromFile(Path.Combine(directory, basename + ".png")); metadata.ExitSection(); return(new PE3SimpleDATTexture(rawHeader, img)); }
public TextureFormat Import(MetadataReader metadata, string directory) { metadata.EnterSection("TX48Texture"); string basename = metadata.GetAttribute <string>("Basename"); metadata.EnterSection("TX48Segment"); int bpp = metadata.Get <int>("Bpp"); Image img = Image.FromFile(Path.Combine(directory, basename + ".png")); metadata.ExitSection(); metadata.ExitSection(); PalettedTextureFormat segment = new PalettedTextureFormat.Builder() .SetPaletteCodec(ColorCodec.CODEC_32BIT_RGBA) .SetIndexCodec(IndexCodec.FromBitPerPixel(bpp)) .Build(img); TX48Texture texture = new TX48Texture(); texture.TextureFormats.Add(segment); return(texture); }
private void Readmetadata(MetadataReader metadata, out TIM2Segment.TIM2SegmentParameters parameters, out string basename, out int palCount) { metadata.EnterSection("TIM2Texture"); basename = metadata.GetAttribute <string>("Basename"); palCount = metadata.GetAttribute <int>("Cluts"); parameters = new TIM2Segment.TIM2SegmentParameters(); parameters.swizzled = swizzled; parameters.linearPalette = metadata.GetAttribute <bool>("LinearClut"); parameters.width = metadata.Get <int>("Width"); parameters.height = metadata.Get <int>("Height"); parameters.bpp = metadata.Get <byte>("Bpp"); parameters.colorSize = metadata.Get <int>("ColorSize"); parameters.mipmapCount = metadata.Get <byte>("MipmapCount"); parameters.format = metadata.Get <byte>("Format"); parameters.GsTEX0 = metadata.Get <byte[]>("GsTEX0"); parameters.GsTEX1 = metadata.Get <byte[]>("GsTEX1"); parameters.GsRegs = metadata.Get <uint>("GsRegs"); parameters.GsTexClut = metadata.Get <uint>("GsTexClut"); parameters.userdata = metadata.Get <byte[]>("UserData"); metadata.ExitSection(); }