void ProcessRes() { for (uint i = 0; i < section_count; i++) { sections[i] = new Section(GetSectionData(i)); switch (sections[i].type) { case "kind": hrefs_sec = new HREF_Section(sections[i].raw); sections[i] = hrefs_sec; break; case "CRES": sections[i] = new CRES_Section(sections[i]); image_sections.Add((int)i); break; default: if (Util.GetUInt32(sections[i].raw, 0) == 0xa0a0a0a0) { sections[i] = new PlaceHolder_Section(sections[i]); } break; } } }
string AddImage(int id) { string name = null; byte[] data = null; if (azw6 != null) { int r = azw6.image_sections.Find(s => s == (id + 1)); if (r != 0) { CRES_Section sec = (CRES_Section)azw6.sections[r]; name = ImageNameHD(id, sec); data = sec.img; sec.comment = name; azw3.sections[azw3.mobi_header.first_res_index + id].comment = name + " (HD version in azw6)"; } } if (name == null) { Image_Section section = (Image_Section)azw3.sections[azw3.mobi_header.first_res_index + id]; name = ImageName(id, section); data = section.raw; section.comment = name; } if (img_names.Find(s => s == name) != null) { return(name); } imgs.Add(data); img_names.Add(name); return(name); }
static void DumpHDImage(string[] args) { Log.log("Dump azw.res"); Log.log("azw6 source:" + args[0]); string outputdir = ""; if (!File.Exists(args[0])) { Log.log("File was not found:" + args[0]); return; } Azw6File azw = new Azw6File(args[0]); if (args.Length >= 3) { outputdir = args[1]; } else { outputdir = Path.Combine(Path.GetDirectoryName(args[0]), azw.header.title); } if (!CreateDirectory(outputdir)) { return; } foreach (var a in azw.image_sections) { CRES_Section sec = (CRES_Section)azw.sections[a]; string filename = Epub.ImageNameHD(a - 1, sec); File.WriteAllBytes(Path.Combine(outputdir, filename), sec.img); Log.log("Saved:" + Path.Combine(outputdir, filename)); } }
public static string ImageNameHD(int resid, CRES_Section section) { return("embed" + Util.Number(resid) + "_HD" + section.ext); }