IngredientArchive¶
Namespace Nfty.Core.Formats in assembly Nfty.Core.
Reads and writes .igt archives — a manifest plus one PNG per variant, plus an optional depth map per variant. The ZipArchive overloads exist so a Recipe can nest one without going through a file.
Methods¶
Read(ZipArchive, Parallelism?)¶
Reads an Ingredient from an already-open archive, decoding every variant PNG.
Parameters
zip(ZipArchive) - The open archive.parallelism(Parallelism?) - How wide PNG encoding (or decoding) may run; null meansParallelism.Default. Never changes the bytes.
Returns. The loaded ingredient; the caller owns it. Its manifest's PartialAlpha is recomputed from the decoded images rather than trusting the stored value.
Exceptions
UnsupportedSchemaVersionException- A manifest declares a schema this build does not read: newer thanSchema.Current, or older thanSchema.Oldest.InvalidDataException- A stored depth entry's length disagrees with its variant image's dimensions.
Read(string, Parallelism?)¶
Reads an Ingredient from a file, decoding every variant PNG.
Parameters
path(string) - Archive path.parallelism(Parallelism?) - How wide PNG encoding (or decoding) may run; null meansParallelism.Default. Never changes the bytes.
Returns. The loaded ingredient; the caller owns it and must dispose it.
Exceptions
InvalidDataException- The archive, or a manifest or image inside it, is missing or unreadable.UnsupportedSchemaVersionException- A manifest declares a schema this build does not read: newer thanSchema.Current, or older thanSchema.Oldest.
ReadAsync(ZipArchive, CancellationToken, Parallelism?)¶
public static Task<LoadedIngredient> ReadAsync(ZipArchive zip, CancellationToken ct = default, Parallelism? parallelism = null);
Reads an Ingredient from an already-open archive.
Parameters
zip(ZipArchive) - The open archive.ct(CancellationToken) - Cancels the read; anything already decoded is disposed first.parallelism(Parallelism?) - How wide PNG encoding (or decoding) may run; null meansParallelism.Default. Never changes the bytes.
Returns. The loaded ingredient; the caller owns it. Its manifest's PartialAlpha is recomputed from the decoded images rather than trusting the stored value.
Exceptions
UnsupportedSchemaVersionException- A manifest declares a schema this build does not read: newer thanSchema.Current, or older thanSchema.Oldest.InvalidDataException- A stored depth entry's length disagrees with its variant image's dimensions.
ReadAsync(string, CancellationToken, Parallelism?)¶
public static Task<LoadedIngredient> ReadAsync(string path, CancellationToken ct = default, Parallelism? parallelism = null);
Reads an Ingredient from a file.
Parameters
path(string) - Archive path.ct(CancellationToken) - Cancels the read; anything already decoded is disposed first.parallelism(Parallelism?) - How wide decoding may run; null meansParallelism.Default.
Returns. The loaded ingredient; the caller owns it.
Exceptions
InvalidDataException- The archive, or a manifest or image inside it, is missing or unreadable.UnsupportedSchemaVersionException- A manifest declares a schema this build does not read: newer thanSchema.Current, or older thanSchema.Oldest.OperationCanceledException-ctwas canceled.
Write(ZipArchive, IngredientManifest, IReadOnlyDictionary<string, Image<Rgba32>>, IReadOnlyDictionary<string, DepthMap>, Parallelism?)¶
public static void Write(ZipArchive zip, IngredientManifest manifest, IReadOnlyDictionary<string, Image<Rgba32>> variantImages, IReadOnlyDictionary<string, DepthMap> depths, Parallelism? parallelism = null);
Writes an Ingredient into an already-open archive.
Parameters
zip(ZipArchive) - The open archive.manifest(IngredientManifest) - The ingredient's manifest. ItsPartialAlphais ignored — the written value is recomputed fromvariantImages.variantImages(IReadOnlyDictionary<string, Image<Rgba32>>) - One image per variant id.depths(IReadOnlyDictionary<string, DepthMap>) - Depth maps by variant id. A variant with no entry, or whose entry is flat once zeroed over transparency, gets nodepth/entry at all. An entry whose key is not one of this manifest's variants is ignored.parallelism(Parallelism?) - How wide PNG encoding (or decoding) may run; null meansParallelism.Default. Never changes the bytes.
Write(string, IngredientManifest, IReadOnlyDictionary<string, Image<Rgba32>>, IReadOnlyDictionary<string, DepthMap>, Parallelism?)¶
public static void Write(string path, IngredientManifest manifest, IReadOnlyDictionary<string, Image<Rgba32>> variantImages, IReadOnlyDictionary<string, DepthMap> depths, Parallelism? parallelism = null);
Writes an Ingredient to a file.
Parameters
path(string) - Destination path.manifest(IngredientManifest) - The ingredient's manifest.variantImages(IReadOnlyDictionary<string, Image<Rgba32>>) - One image per variant id.depths(IReadOnlyDictionary<string, DepthMap>) - Depth maps by variant id.parallelism(Parallelism?) - How wide PNG encoding (or decoding) may run; null meansParallelism.Default. Never changes the bytes.
WriteAsync(ZipArchive, IngredientManifest, IReadOnlyDictionary<string, Image<Rgba32>>, IReadOnlyDictionary<string, DepthMap>, CancellationToken, Parallelism?)¶
public static Task WriteAsync(ZipArchive zip, IngredientManifest manifest, IReadOnlyDictionary<string, Image<Rgba32>> variantImages, IReadOnlyDictionary<string, DepthMap> depths, CancellationToken ct = default, Parallelism? parallelism = null);
Writes an Ingredient into an already-open archive.
Parameters
zip(ZipArchive) - The open archive.manifest(IngredientManifest) - The ingredient's manifest.variantImages(IReadOnlyDictionary<string, Image<Rgba32>>) - One image per variant id.depths(IReadOnlyDictionary<string, DepthMap>) - Depth maps by variant id. See the sync overload for the write rules.ct(CancellationToken) - Cancels the write.parallelism(Parallelism?) - How wide PNG encoding (or decoding) may run; null meansParallelism.Default. Never changes the bytes.
Returns. A task that completes when it is written.
WriteAsync(string, IngredientManifest, IReadOnlyDictionary<string, Image<Rgba32>>, IReadOnlyDictionary<string, DepthMap>, CancellationToken, Parallelism?)¶
public static Task WriteAsync(string path, IngredientManifest manifest, IReadOnlyDictionary<string, Image<Rgba32>> variantImages, IReadOnlyDictionary<string, DepthMap> depths, CancellationToken ct = default, Parallelism? parallelism = null);
Writes an Ingredient to a file.
Parameters
path(string) - Destination path.manifest(IngredientManifest) - The ingredient's manifest.variantImages(IReadOnlyDictionary<string, Image<Rgba32>>) - One image per variant id.depths(IReadOnlyDictionary<string, DepthMap>) - Depth maps by variant id.ct(CancellationToken) - Cancels the write.parallelism(Parallelism?) - How wide PNG encoding (or decoding) may run; null meansParallelism.Default. Never changes the bytes.
Returns. A task that completes when it is written.