protected int OnExecute(CommandLineApplication app) { var outputDir = OutputDir ?? Path.Combine(Path.GetDirectoryName(InputIso), "extract"); using var stream = File.OpenRead(InputIso); var firstBlock = IsoUtility.GetFileOffset(stream, "SYSTEM.CNF;1"); if (firstBlock == -1) { throw new IOException("The file specified seems to not be a valid PlayStation 2 ISO."); } var kingdomIdxBlock = IsoUtility.GetFileOffset(stream, "KINGDOM.IDX;1"); if (kingdomIdxBlock == -1) { throw new IOException("The file specified seems to not be a Kingdom Hearts 1 ISO"); } var idx = Idx1.Read(stream.SetPosition(kingdomIdxBlock * IsoBlockAlign)); var img = new Img1(stream, idx, firstBlock); ExtractIdx(img, outputDir, DoNotExtractAgain); return(0); }
public static void ExtractIdx( Img1 img, string basePath, bool doNotExtractAgain) { foreach (var entry in img.Entries) { var fileName = entry.Key; if (fileName == null) { fileName = $"@noname/{entry.Value.Hash:X08}"; } var outputFile = Path.Combine(basePath, fileName); if (doNotExtractAgain && File.Exists(outputFile)) { continue; } var outputDir = Path.GetDirectoryName(outputFile); if (Directory.Exists(outputDir) == false) { Directory.CreateDirectory(outputDir); } Console.WriteLine(fileName); using var file = File.Create(outputFile); img.FileOpen(entry.Value).CopyTo(file); } }
void ReleaseDesignerOutlets() { if (Img1 != null) { Img1.Dispose(); Img1 = null; } if (Btn1 != null) { Btn1.Dispose(); Btn1 = null; } if (Img3 != null) { Img3.Dispose(); Img3 = null; } if (Btn3 != null) { Btn3.Dispose(); Btn3 = null; } if (Img2 != null) { Img2.Dispose(); Img2 = null; } if (Btn2 != null) { Btn2.Dispose(); Btn2 = null; } if (Img4 != null) { Img4.Dispose(); Img4 = null; } if (Btn4 != null) { Btn4.Dispose(); Btn4 = null; } }
public void Compare() { _exceptedPoints = new List <Point>(); double acceptableDelta = 255 * 3 * 0.1; int width = Math.Min(Img1.Width, Img2.Width); int height = Math.Min(Img1.Height, Img2.Height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { var color1 = Img1.GetPixel(i, j); var color2 = Img2.GetPixel(i, j); if (Math.Abs(GetSum(color1) - GetSum(color2)) > acceptableDelta) { _exceptedPoints.Add(new Point(i, j)); } } } FindAreas(); }