using Newtonsoft.Json;using SixLabors.ImageSharp;using SixLabors.ImageSharp.PixelFormats;using WaxMapArt;// Load the default palette.Palettepalette= JsonConvert.DeserializeObject<Palette>(File.ReadAllText("palette.json"));// Load image from path.Image<Rgb24>image= Image.Load<Rgb24>("image.jpg");// Create the configuration to generate preview.Previewpreview=new Preview(palette){// Change the color comparison method.Method= ComparisonMethod.Cie76,// Amount of maps (X = width, Y = height).MapSize=new WaxSize(1,1),// Change the output size of the preview image.OutputSize=new WaxSize(512,512)};// Generate the preview.PreviewOutputpreviewOutput= preview.GeneratePreviewStaircase(image);// Or preview.GeneratePreviewFlat(image) for flat generation// Save the preview in a file.
previewOutput.Image.SaveAsPng("preview.png");// Interact with all necessary blocks.foreach(var(mapId, count)in previewOutput.BlockList){intpacks=count/64;intrem=count%64;doubleshulkers= Math.Truncate(packs/27f*100)/100;stringpackCount=packs>0?$"{packs} packs + {rem}": count.ToString();// Get the block id from the map id.stringid= palette.Colors[mapId.ToString()].BlockId;// Print the result.
Console.WriteLine(id);
Console.WriteLine($"Shulker box: {shulkers}");
Console.WriteLine(packCount);
Console.WriteLine();}
Generating schematic file (NBT) (C#)
using Newtonsoft.Json;using SixLabors.ImageSharp;using SixLabors.ImageSharp.PixelFormats;using WaxMapArt;// Load the default palette.Palettepalette= JsonConvert.DeserializeObject<Palette>(File.ReadAllText("palette.json"));// Load image from path.Image<Rgb24>image= Image.Load<Rgb24>("image.jpg");// Create the configuration to generate blocks.Generatorgenerator=new Generator(palette){// Change the color comparison method.Method= ComparisonMethod.Cie76,// Amount of maps (X = width, Y = height).MapSize=new WaxSize(1,1),// Change the output size of the preview image.OutputSize=new WaxSize(512,512)};// Generate the list of blocks.GeneratorOutputgeneratorOutput= generator.GenerateStaircase(image);// Or generator.GenerateFlat(image) for flat generation// Save the preview in a file.
generatorOutput.Image.SaveAsPng("preview.png");// Interact with all necessary blocks.foreach(var(info, count)in generatorOutput.CountBlocks()){intpacks=count/64;intrem=count%64;doubleshulkers= Math.Truncate(packs/27f*100)/100;stringpackCount=packs>0?$"{packs} packs + {rem}": count.ToString();// Get the block id from the map id.stringid= info.BlockId;// Print the result.
Console.WriteLine(id);
Console.WriteLine($"Shulker box: {shulkers}");
Console.WriteLine(packCount);
Console.WriteLine();}// Finally, generate the NBT.Streamstream= NbtGenerator.Generate(generatorOutput.Blocks);// Save the NBT.usingFileStreamfs= File.Create("schematic.nbt");
stream.CopyTo(fs);
stream.Close();
fs.Close();