Exemplo n.º 1
0
        /* Phases:
         * 1 - Load image
         * 2 - Quantize/Prerender image
         * 3 - Generate blueprint/ map to colors
         * 4 - Generate PNG image (layer 1)
         * 4b - Generate layer 2
         * 4c - Shadows
         * 4d - WorldEdit Origin
         * 4e - Grid
         * 4f - Border
         * 5 - Save to file
         */
        public static async Task writePNG(System.Threading.CancellationToken _worker, string filePath, Bitmap inputImage)
        {
            Console.WriteLine("Resizing image...");
            Bitmap resized = PngFormatter.ResizeAndFormatRawImage(inputImage);

            //inputImage.DisposeSafely();

            Console.WriteLine("Quantizing image...");
            PngFormatter.QuantizeImage(_worker, ref resized);

            Console.WriteLine("Converting pixels to Minecraft materials...");
            BlueprintPA blueprint = await BlueprintPA.GetBluePrintAsync(_worker, resized);

            resized.DisposeSafely();

            Console.WriteLine("Rendering to bitmap...");
            Bitmap rendered = RenderBitmapFromBlueprint(_worker, blueprint, out int?textureSize);

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            rendered.Save(filePath, ImageFormat.Png);
        }
Exemplo n.º 2
0
        public static async Task writeSchemFromImage(System.Threading.CancellationToken _worker, string filePath, Bitmap inputImage)
        {
            Console.WriteLine("Resizing image...");
            Bitmap resized = PngFormatter.ResizeAndFormatRawImage(inputImage);

            //inputImage.DisposeSafely();

            Console.WriteLine("Quantizing image...");
            PngFormatter.QuantizeImage(_worker, ref resized);

            Console.WriteLine("Converting pixels to Minecraft materials...");
            BlueprintPA blueprint = await BlueprintPA.GetBluePrintAsync(_worker, resized);

            resized.DisposeSafely();

            Schem2Formatter.writeBlueprint(filePath, blueprint);
        }