def _copyFromClipboard(size=None): """ Looks into the clipboard to see if an image is present and extract it if this is the case. This function works only on Windows. Returns a mamba image or None if no image was found. """ import platform im = None if platform.system() == 'Windows': # Under Windows from PIL import ImageGrab # The image is extracted from the clipboard. # !! There is a bug in PIL 1.1.6 with the clipboard: # !! it is not closed if there is no image in it # !! and thus this can have very bad effects on Windows # !! copy/paste operations. im_clipbd = ImageGrab.grabclipboard() if im_clipbd != None: im = utils.loadFromPILFormat(im_clipbd, size=size) return im
def _copyFromClipboard(size=None): """ Looks into the clipboard to see if an image is present and extract it if this is the case. This function works only on Windows. Returns a mamba image or None if no image was found. """ import platform im = None if platform.system()=='Windows': # Under Windows from PIL import ImageGrab # The image is extracted from the clipboard. # !! There is a bug in PIL 1.1.6 with the clipboard: # !! it is not closed if there is no image in it # !! and thus this can have very bad effects on Windows # !! copy/paste operations. im_clipbd = ImageGrab.grabclipboard() if im_clipbd!=None: im = utils.loadFromPILFormat(im_clipbd, size=size) return im
def PIL2Mamba(pilim, imOut): """ The PIL/PILLOW image 'pilim' is used to load the Mamba image 'imOut'. """ depth = imOut.getDepth() (width, height) = imOut.getSize() next_mbIm = utils.loadFromPILFormat(pilim, size=(width,height)) err = core.MB_Convert(next_mbIm, imOut.mbIm) mamba.raiseExceptionOnError(err) imOut.update()