def processImage(i, files, rscnames, sect, data, beg, rsc_ptr, cover_offset): global DUMP # Extract an Image imgtype = get_image_type(None, data) if imgtype is None: print "Warning: Section %s does not contain a recognised resource" % i rscnames.append(None) sect.setsectiondescription( i, "Mysterious Section, first four bytes %s" % describe(data[0:4])) if DUMP: fname = "unknown%05d.dat" % i outname = os.path.join(files.outdir, fname) open(pathof(outname), 'wb').write(data) sect.setsectiondescription( i, "Mysterious Section, first four bytes %s extracting as %s" % (describe(data[0:4]), fname)) return rscnames, rsc_ptr imgname = "image%05d.%s" % (i, imgtype) if cover_offset is not None and i == beg + cover_offset: imgname = "cover%05d.%s" % (i, imgtype) print "Extracting image: {0:s} from section {1:d}".format(imgname, i) outimg = os.path.join(files.imgdir, imgname) open(pathof(outimg), 'wb').write(data) rscnames.append(imgname) sect.setsectiondescription(i, "Image {0:s}".format(imgname)) if rsc_ptr == -1: rsc_ptr = i - beg return rscnames, rsc_ptr
def processCRES(i, files, imgnames, sect, data, beg, image_ptr, use_hd): # extract an HDImage global DUMP data = data[12:] imgtype = get_image_type(None, data) if imgtype is None: print "Warning: CRES Section %s does not contain a recognised resource" % i imgnames.append(None) sect.setsectiondescription(i,"Mysterious CRES data, first four bytes %s" % describe(data[0:4])) if DUMP: fname = "unknown%05d.dat" % i outname= os.path.join(files.outdir, fname) open(pathof(outname), 'wb').write(data) sect.setsectiondescription(i,"Mysterious CRES data, first four bytes %s extracting as %s" % (describe(data[0:4]), fname)) image_ptr += 1 return imgnames, image_ptr if use_hd: # overwrite corresponding lower res image with hd version imgname = imgnames[image_ptr] imgdest = files.imgdir else: imgname = "HDimage%05d.%s" % (i, imgtype) imgdest = files.hdimgdir print "Extracting HD image: {0:s} from section {1:d}".format(imgname,i) outimg = os.path.join(imgdest, imgname) open(pathof(outimg), 'wb').write(data) imgnames.append(None) sect.setsectiondescription(i,"Optional HD Image {0:s}".format(imgname)) image_ptr += 1 return imgnames, image_ptr
def processImage(i, files, imgnames, sect, data, beg, image_ptr, cover_offset): global DUMP # Extract an Image imgtype = get_image_type(None, data) if imgtype is None: print "Warning: Section %s does not contain a recognised resource" % i imgnames.append(None) sect.setsectiondescription(i,"Mysterious Section, first four bytes %s" % describe(data[0:4])) if DUMP: fname = "unknown%05d.dat" % i outname= os.path.join(files.outdir, fname) open(pathof(outname), 'wb').write(data) sect.setsectiondescription(i,"Mysterious Section, first four bytes %s extracting as %s" % (describe(data[0:4]), fname)) return imgnames, image_ptr imgname = "image%05d.%s" % (i, imgtype) if cover_offset is not None and i == beg + cover_offset: imgname = "cover%05d.%s" % (i, imgtype) print "Extracting image: {0:s} from section {1:d}".format(imgname,i) outimg = os.path.join(files.imgdir, imgname) open(pathof(outimg), 'wb').write(data) imgnames.append(imgname) sect.setsectiondescription(i,"Image {0:s}".format(imgname)) if image_ptr == -1: image_ptr = i - beg return imgnames, image_ptr
def processCRES(i, files, rscnames, sect, data, beg, rsc_ptr, use_hd): # extract an HDImage global DUMP data = data[12:] imgtype = get_image_type(None, data) if imgtype is None: print("Warning: CRES Section %s does not contain a recognised resource" % i) rscnames.append(None) sect.setsectiondescription(i,"Mysterious CRES data, first four bytes %s" % describe(data[0:4])) if DUMP: fname = "unknown%05d.dat" % i outname= os.path.join(files.outdir, fname) with open(pathof(outname), 'wb') as f: f.write(data) sect.setsectiondescription(i,"Mysterious CRES data, first four bytes %s extracting as %s" % (describe(data[0:4]), fname)) rsc_ptr += 1 return rscnames, rsc_ptr if use_hd: # overwrite corresponding lower res image with hd version imgname = rscnames[rsc_ptr] imgdest = files.imgdir else: imgname = "HDimage%05d.%s" % (i-beg+1, imgtype) imgdest = files.hdimgdir print("Extracting HD image: {0:s} from section {1:d}".format(imgname,i-beg+1)) outimg = os.path.join(imgdest, imgname) with open(pathof(outimg), 'wb') as f: f.write(data) rscnames.append(None) sect.setsectiondescription(i,"Optional HD Image {0:s}".format(imgname)) rsc_ptr += 1 return rscnames, rsc_ptr