def Mamba2PIL(imIn): """ Creates and returns a PIL/PILLOW image using the Mamba image 'imIn'. If the mamba image uses a palette, it will be integrated inside the PIL/PILLOW image. """ return utils.convertToPILFormat(imIn.mbIm)
def updateim(self): # Updates the display (perform a rendering) volume = m3D.computeVolume3D(self.im_ref()) if self.im_ref().getDepth() == 32: immb = mamba.imageMb(self.im_ref()[self.z], 8) if self.master.bplane == 4: mamba.convert(self.im_ref()[self.z], immb) self.planeLabel.config(text="Plane : all") else: mamba.copyBytePlane(self.im_ref()[self.z], self.master.bplane, immb) self.planeLabel.config(text="Plane : %d" % (self.master.bplane)) im = utils.convertToPILFormat(immb.mbIm) else: self.planeLabel.config(text="") im = utils.convertToPILFormat(self.im_ref()[self.z].mbIm) if self.master.palname: im.putpalette(palette.getPalette(self.master.palname)) self.planez.display(im) self.volLabel.config(text="Volume : %d" % (volume)) value = self.im_ref().getPixel((self.x, self.y, self.z)) self.posLabel.config(text="At (%d,%d,%d) = %d" % (self.x, self.y, self.z, value))
def updateim(self): # Updates the display with the new contents of the mamba image. if self.im_ref() and self.state()=="normal" and not self.frozen: if self.im_ref().getDepth()==32: im = mamba.imageMb(self.im_ref(), 8) if self.bplane==4: mamba.convert(self.im_ref(), im) self.infos[1].set("plane : all") else: mamba.copyBytePlane(self.im_ref(),self.bplane,im) self.infos[1].set("plane : %d" % (self.bplane)) self.pilImage = utils.convertToPILFormat(im.mbIm) else: self.infos[1].set("") self.pilImage = utils.convertToPILFormat(self.im_ref().mbIm) if self.palname: self.pilImage.putpalette(palette.getPalette(self.palname)) volume = mamba.computeVolume(self.im_ref()) self.infos[0].set("volume : "+str(volume)) self.icon = ImageTk.PhotoImage(self.pilImage.resize(self.icon_size, Image.NEAREST)) self.tk.call('wm','iconphoto', self._w, self.icon) self.drawImage()
def updateim(self): # Updates the display with the new contents of the mamba image. if self.im_ref() and self.state() == "normal" and not self.frozen: if self.im_ref().getDepth() == 32: im = mamba.imageMb(self.im_ref(), 8) if self.bplane == 4: mamba.convert(self.im_ref(), im) self.infos[1].set("plane : all") else: mamba.copyBytePlane(self.im_ref(), self.bplane, im) self.infos[1].set("plane : %d" % (self.bplane)) self.pilImage = utils.convertToPILFormat(im.mbIm) else: self.infos[1].set("") self.pilImage = utils.convertToPILFormat(self.im_ref().mbIm) if self.palname: self.pilImage.putpalette(palette.getPalette(self.palname)) volume = mamba.computeVolume(self.im_ref()) self.infos[0].set("volume : " + str(volume)) self.icon = ImageTk.PhotoImage( self.pilImage.resize(self.icon_size, Image.NEAREST)) self.tk.call('wm', 'iconphoto', self._w, self.icon) self.drawImage()
def save(self, path, palette=None): """ Saves the image at the corresponding 'path' using PIL/PILLOW library. The format is automatically deduced by PIL/PILLOW from the image name extension. Make sure the format support the image depth (e.g 32-bit image cannot be stored in JPEG) and use uncompressed format if you wish to reload the image unaltered later. You can add a 'palette' to the saved image (note that it may alter the pixels value if you wish to reload the image later). """ pilim = utils.convertToPILFormat(self.mbIm) if self.mbIm.depth!=32 and palette: pilim.putpalette(palette) pilim = pilim.convert("RGB") pilim.save(path)