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); }
void ProcessRes() { for (uint i = mobi_header.first_res_index; i < section_count; i++) { sections[i] = new Section(GetSectionData(i)); switch (sections[i].type) { case "FDST": sections[i] = new FDST_Section(sections[i]); fdst = (FDST_Section)sections[i]; break; case "RESC": sections[i] = new RESC_Section(sections[i]); resc = (RESC_Section)sections[i]; break; default: string r = Util.GuessImageType(sections[i].raw); if (r != null) { sections[i] = new Image_Section(sections[i], r); } break; } } }
string ImageName(int resid, Image_Section section) { return("embed" + Util.Number(resid) + section.ext); }