Example #1
0
        private static void ImportTestBackground(string mapFile, string imgFile, string palFile)
        {
            FileStream   oldPalStr = new FileStream(palFile, FileMode.Open);
            FileStream   oldImgStr = new FileStream(imgFile, FileMode.Open);
            FileStream   oldMapStr = new FileStream(mapFile, FileMode.Open);
            MemoryStream newPalStr = new MemoryStream();
            MemoryStream newImgStr = new MemoryStream();
            MemoryStream newMapStr = new MemoryStream();

            Nclr      nclr = new Nclr(oldPalStr);
            Ncgr      ncgr = new Ncgr(oldImgStr);
            Nscr      nscr = new Nscr(oldMapStr);
            EmguImage bmp  = nscr.CreateBitmap(ncgr, nclr);

            bmp.Save(mapFile + ".png");

            BackgroundImporter importer = new BackgroundImporter();

            importer.ImportBackground(bmp, newMapStr, newImgStr, newPalStr);

            if (!Compare(oldPalStr, newPalStr))
            {
                string newPalFile = palFile + ".new";
                WriteStream(newPalFile, newPalStr);
                Console.WriteLine("Palette different... Written to {0}", newPalFile);
            }
            if (!Compare(oldImgStr, newImgStr))
            {
                string newImgFile = imgFile + ".new";
                WriteStream(newImgFile, newImgStr);
                Console.WriteLine("Image different...   Written to {0}", newImgFile);
            }
            if (!Compare(oldMapStr, newMapStr))
            {
                string newMapFile = mapFile + ".new";
                WriteStream(newMapFile, newMapStr);
                Console.WriteLine("Map different...     Written to {0}", newMapFile);
            }

            newPalStr.Position = newImgStr.Position = newMapStr.Position = 0;
            nclr = new Nclr(newPalStr);
            ncgr = new Ncgr(newImgStr);
            nscr = new Nscr(newMapStr);
            nscr.CreateBitmap(ncgr, nclr).Save(mapFile + "m.png");

            oldPalStr.Close();
            oldImgStr.Close();
            oldMapStr.Close();
            newPalStr.Close();
            newImgStr.Close();
            newMapStr.Close();
        }
Example #2
0
        private static void ImportTestBackground(string mapFile, string imgFile, string palFile)
        {
            FileStream   oldPalStr = new FileStream(palFile, FileMode.Open);
            FileStream   oldImgStr = new FileStream(imgFile, FileMode.Open);
            FileStream   oldMapStr = new FileStream(mapFile, FileMode.Open);
            MemoryStream newPalStr = new MemoryStream();
            MemoryStream newImgStr = new MemoryStream();
            MemoryStream newMapStr = new MemoryStream();

            Nclr nclr = new Nclr(oldPalStr);
            Ncgr ncgr = new Ncgr(oldImgStr);
            Nscr nscr = new Nscr(oldMapStr);
            EmguImage bmp = nscr.CreateBitmap(ncgr, nclr);
            bmp.Save(mapFile + ".png");

            BackgroundImporter importer = new BackgroundImporter();
            importer.ImportBackground(bmp, newMapStr, newImgStr, newPalStr);

            if (!Compare(oldPalStr, newPalStr)) {
                string newPalFile = palFile + ".new";
                WriteStream(newPalFile, newPalStr);
                Console.WriteLine("Palette different... Written to {0}", newPalFile);
            }
            if (!Compare(oldImgStr, newImgStr)) {
                string newImgFile = imgFile + ".new";
                WriteStream(newImgFile, newImgStr);
                Console.WriteLine("Image different...   Written to {0}", newImgFile);
            }
            if (!Compare(oldMapStr, newMapStr)) {
                string newMapFile = mapFile + ".new";
                WriteStream(newMapFile, newMapStr);
                Console.WriteLine("Map different...     Written to {0}", newMapFile);
            }

            newPalStr.Position = newImgStr.Position = newMapStr.Position = 0;
            nclr = new Nclr(newPalStr);
            ncgr = new Ncgr(newImgStr);
            nscr = new Nscr(newMapStr);
            nscr.CreateBitmap(ncgr, nclr).Save(mapFile + "m.png");

            oldPalStr.Close();
            oldImgStr.Close();
            oldMapStr.Close();
            newPalStr.Close();
            newImgStr.Close();
            newMapStr.Close();
        }