예제 #1
0
        private static void ImportDig(Node nDIG, Node nATM, Node nPNG, string outputPath)
        {
            log.Info("Importing " + nDIG.Name + ", " + nATM.Name + " and " + nPNG.Name);

            DIG  originalDig = nDIG.TransformWith <Binary2DIG>().GetFormatAs <DIG>();
            ALMT originalAtm = nATM.TransformWith <Binary2ALMT>().GetFormatAs <ALMT>();

            // New stream
            var stream     = new MemoryStream();
            var dataStream = DataStreamFactory.FromStreamKeepingOwnership(stream, 0, 0);

            // Copy the png to the bitmap stream
            nPNG.Stream.WriteTo(dataStream);

            // Import the new PNG file
            Bitmap newImage = (Bitmap)Image.FromStream(stream);

            var         quantization = new FixedPaletteQuantization(originalDig.Palette.GetPalette(0));
            ColorFormat format;

            if (originalDig.PaletteType == 16)
            {
                format = ColorFormat.Indexed_4bpp;
            }
            else
            {
                format = ColorFormat.Indexed_8bpp;
            }

            Texim.ImageMapConverter importer = new Texim.ImageMapConverter
            {
                Format        = format,
                PixelEncoding = PixelEncoding.HorizontalTiles,
                Quantization  = quantization,
                //Mapable = new MatchMapping(originalDig.Pixels.GetPixels())
            };

            (Palette _, PixelArray pixelInfo, MapInfo[] mapInfos) = importer.Convert(newImage);

            originalDig.Pixels = pixelInfo;
            originalAtm.Info   = mapInfos;

            BinaryFormat bDig = (BinaryFormat)ConvertFormat.With <Binary2DIG>(originalDig);
            BinaryFormat bAtm = (BinaryFormat)ConvertFormat.With <Binary2ALMT>(originalAtm);

            Utils.Lzss(bDig, "-evn").Stream.WriteTo(Path.Combine(outputPath, nDIG.Name + ".evn.dig"));
            bAtm.Stream.WriteTo(Path.Combine(outputPath, nATM.Name + ".atm"));
        }
예제 #2
0
        private static void ExportDig(Node nDIG, Node nATM, string outputPath)
        {
            log.Info("Exporting " + nDIG.Name);

            DIG dig = nDIG.TransformWith <Binary2DIG>().GetFormatAs <DIG>();

            ALMT atm = nATM.TransformWith <Binary2ALMT>().GetFormatAs <ALMT>();

            Bitmap img = atm.CreateBitmap(dig.Pixels, dig.Palette);

            string path = Path.Combine(outputPath, nDIG.Name + ".png");

            img.Save(path);

            log.Info("Saved into " + path);
        }