public void Export(TextureFormat texture, Metadata.MetadataWriter metadata, string directory, string basename) { if (texture.GetType() != typeof(T)) { throw new TextureFormatException("Wrong TextureFormat type, expected: " + typeof(T).FullName); } metadata.BeginSection(MetadataID); metadata.PutAttribute("Textures", texture.FramesCount); metadata.PutAttribute("Basename", basename); metadata.BeginSection("GeneralMetadata"); OnExportGeneralTextureMetadata((T)texture, metadata); metadata.EndSection(); int oldSelected = texture.SelectedFrame; for (int frame = 0; frame < texture.FramesCount; frame++) { texture.SelectedFrame = frame; metadata.BeginSection("FrameMetadata"); metadata.PutAttribute("PalettesCount", texture.PalettesCount); metadata.PutAttribute("MipmapsCount", texture.MipmapsCount); OnExportFrameMetadata((T)texture, frame, metadata); metadata.EndSection(); int i = 0; Image referenceImage; ICollection <Image> list = ConstructImages(texture, out referenceImage); foreach (Image img in list) { string fullPath = Path.Combine(directory, basename + "_layer" + frame + "_" + i++ + ".png"); if (img != null) { img.Save(fullPath); } else { File.WriteAllText(fullPath, string.Empty); } } if (referenceImage != null) { referenceImage.Save(Path.Combine(directory, basename + "_layer" + frame + "_reference.png")); } } texture.SelectedFrame = oldSelected; metadata.EndSection(); }
protected virtual void OnExportFrameMetadata(T texture, int frame, Metadata.MetadataWriter metadata) { TextureFormat tFrame = GetTextureFrame(texture, frame); InteropUtils.WriteTo(tFrame.FormatSpecificData, metadata); }
protected virtual void OnExportGeneralTextureMetadata(T texture, Metadata.MetadataWriter metadata) { InteropUtils.WriteTo(texture.FormatSpecificData, metadata); }