示例#1
0
        private static void DecodeBitmaps(string inputDirectory, bool ignoreConstraits)
        {
            var table   = TableEntry.LoadFromFile(Path.Combine(inputDirectory, "TABLE.BIN"));
            var imgData = new ImageData(Path.Combine(inputDirectory, "BMPDATA.BIN"));
            var dir     = Directory.CreateDirectory(BitmapsOutputDir).FullName;
            var result  = true;

            Parallel.ForEach(table, (entry) =>
            {
                try
                {
                    imgData.LoadBitmap(entry).Save(Path.Combine(dir, string.Format("{0}_{1}x{2}.bmp", entry.Id, entry.Width, entry.Height)), ImageFormat.Bmp);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(string.Format("ERROR! Failed to convert file {0}!{1}{2}", entry.Id, Environment.NewLine, ex));
                    result = false;
                }
            });
            if (result)
            {
                Console.WriteLine("Decoding finished");
            }
            else
            {
                Console.WriteLine("Decoding failed");
            }
        }
        private static void DecodeBitmaps(string inputDirectory, bool ignoreConstraits)
        {
            var table   = TableEntry.LoadFromFile(Path.Combine(inputDirectory, "TABLE.BIN"));
            var imgData = new ImageData(Path.Combine(inputDirectory, "BMPDATA.BIN"));
            var dir     = Directory.CreateDirectory(BitmapsOutputDir).FullName;
            var result  = true;

            Parallel.ForEach(table, (entry) =>
            {
                try
                {
                    imgData.LoadBitmap(entry).Save(Path.Combine(dir, $"{entry.Id}_{entry.Width}x{entry.Height}.bmp"), ImageFormat.Bmp);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"ERROR! Failed to convert a file with id {entry.Id}!{Environment.NewLine}{ex}");
                    result = false;
                }
            });
            Console.WriteLine($"Decoding {(result ? "finished" : "failed")}");
        }