private void OnImportFrameMetadata(T texture, int frame, Metadata.MetadataReader metadata, IList <Image> images, Image referenceImage, int mipmapsCount) { GenericDictionary formatSpecific = new GenericDictionary(); InteropUtils.ReadFrom(metadata, formatSpecific); TextureFormat segment = CreateFrameForGeneralTexture(texture, frame, formatSpecific, images, referenceImage, mipmapsCount); segment.FormatSpecificData = formatSpecific; }
private T OnImportGeneralTextureMetadata(Metadata.MetadataReader metadata) { GenericDictionary formatSpecific = new GenericDictionary(); InteropUtils.ReadFrom(metadata, formatSpecific); T result = CreateGeneralTextureFromFormatSpecificData(formatSpecific); result.FormatSpecificData = formatSpecific; return(result); }
public bool IsValidMetadataFormat(Metadata.MetadataReader metadata) { try { metadata.EnterSection(MetadataID); } catch (Exception) { metadata.Rewind(); return(false); } metadata.ExitSection(); metadata.Rewind(); return(true); }
public TextureFormat Import(Metadata.MetadataReader metadata, string directory) { metadata.EnterSection(MetadataID); int count = metadata.GetAttribute <int>("Textures"); string basename = metadata.GetAttribute <string>("Basename"); metadata.EnterSection("GeneralMetadata"); T texture = OnImportGeneralTextureMetadata(metadata); metadata.ExitSection(); for (int frame = 0; frame < count; frame++) { metadata.EnterSection("FrameMetadata"); int palCount = metadata.GetAttribute <int>("PalettesCount"); int mipmapsCount = metadata.GetAttribute <int>("MipmapsCount"); IList <Image> images = new List <Image>(); Image referenceImage = null; for (int i = 0; i < (palCount == 0 ? 1 : palCount); i++) { Image img = Image.FromFile(Path.Combine(directory, basename + "_layer" + frame + "_" + i + ".png")); images.Add(img); } if (palCount > 1) { referenceImage = Image.FromFile(Path.Combine(directory, basename + "_layer" + frame + "_reference.png")); } OnImportFrameMetadata(texture, frame, metadata, images, referenceImage, mipmapsCount); metadata.ExitSection(); } metadata.ExitSection(); return(texture); }