def save(self, dst, width, height, palette): # This does not match in OVSLOT.def if width != self.frameWidth: print "Frame width %d does not match def width %d"%(self.frameWidth, width) if height != self.frameHeight: print "Frame height %d does not match def height %d"%(self.frameHeight, height) if self.image == None: print "Invalid frame" return if not os.path.isdir(dst): try: os.makedirs(dst) except: print "Could not create destination directory", dst return if self.filename in ("clrrvr.def", "mudrvr.def", "lavrvr.def", "watrtl.def"): specialDef(dst, palette) else: self.image.putpalette(palette) self.image = self.image.convert("RGBA") data = self.image.load() for x in xrange(self.image.size[0]): for y in xrange(self.image.size[1]): if data[x, y] == (0, 255, 255, 255): data[x, y] = (0, 0, 0, 0) elif data[x, y] == (255, 150, 255, 255): data[x, y] = (0, 0, 0, 64) elif data[x, y] == (255, 151, 255, 255): data[x, y] = (0, 0, 0, 64) elif data[x, y] == (255, 0, 255, 255): data[x, y] = (0, 0, 0, 128) self.image.save(unique.save(dst, "%s.png"%self.filename), "PNG")
def save(self, dst): # Make sure the path to save the file is available dst = os.path.join(dst, "video") if not os.path.isdir(dst): try: os.makedirs(dst) except: print "Could not create destination directory", dst return file = open(unique.save(dst, self.filename), "wb") file.write(self.body) file.close()
def save(self, dst): # Make sure the path to save the file is available dst = os.path.join(dst, self.directories[self.fileType]) if not os.path.isdir(dst): try: os.makedirs(dst) except: print "Could not create destination directory", dst return # If the file has a special processor, order it to save the file as it sees fit. Otherwise, save the binary dump of the body. if self.output: self.output.save(dst, self.filename) else: file = open(unique.save(dst, self.filename), "wb") file.write(self.body) file.close()
def specialSave(self, dst, image, i): dst = os.path.join(dst, "%d.png"%i) self.image.save(unique.save(dst, "%s.png"%i), "PNG")
def save(self, dst, filename): filename = "%s.png"%filename self.image.save(unique.save(dst, filename), "PNG")