private void ExtractAllImages(Pk2Folder folder, string OutPutPath, System.Drawing.Imaging.ImageFormat format) { string ext = format == System.Drawing.Imaging.ImageFormat.Jpeg?"jpg":format.ToString().ToLower(); foreach (Pk2File f in folder.Files) { // Check path if the file already exists string saveFilePath = Path.ChangeExtension(Path.GetFullPath(OutPutPath + f.Name), ext); if (File.Exists(saveFilePath)) { continue; } // 10% display if (rand.Next(1, 1000) <= 100) { LogState("Creating " + f.Name); } // Convert DDJ to DDS to Bitmap Bitmap img = DDSReader.FromDDJ(pk2.GetFileBytes(f)); // Save as png img.Save(saveFilePath, format); } foreach (Pk2Folder f in folder.SubFolders) { ExtractAllImages(f, OutPutPath, format); } }
private void AddMinimap() { string folderPath; LogState("Checking minimap images..."); // Check directory folderPath = "Minimap\\"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } // Get files Pk2Folder minimap = pk2.GetFolder("Minimap"); if (minimap != null) { ExtractAllImages(minimap, folderPath, System.Drawing.Imaging.ImageFormat.Jpeg); } LogState("Checking minimap dungeon images..."); // Check directory folderPath = "Minimap\\d\\"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } // Get files minimap = pk2.GetFolder("Minimap_d"); if (minimap != null) { ExtractAllImages(minimap, folderPath, System.Drawing.Imaging.ImageFormat.Jpeg); } }