Esempio n. 1
0
    def compositeFromCorner(self, image, x, y, compmode, clippath=None, lock=None, refreshimage=True, opacity=1):
        """ Method of BeeTemporaryLayerPIL """
        x = int(x)
        y = int(y)

        # print "compositing image onto pil temp layer:"
        # printPILImage(image)
        # print "calling compositeFromCorner with args:",x,y

        if not lock:
            lock = qtcore.QWriteLocker(self.imagelock)

        width, height = image.size

        rect = qtcore.QRect(x, y, width, height)

        # self.pilimage.paste(image,box=(x,y),mask=image)
        PILcomposite(self.pilimage, image, x, y, ImageCombineTypes.lightest)

        # updatedsection=self.pilimage.crop((x,y,x+image.size[0],y+image.size[1]))
        # print "new section looks like:", x,y,image.size
        # printPILImage(updatedsection)

        dirtyregion = qtgui.QRegion(rect)
        win = BeeApp().master.getWindowById(self.windowid)

        sizelock = qtcore.QReadLocker(win.docsizelock)
        # not every type of window actually has a full image representation so just calculate what the image rectangle would be
        imagerect = qtcore.QRect(0, 0, win.docwidth, win.docheight)

        if refreshimage:
            dirtyregion = dirtyregion.intersect(qtgui.QRegion(imagerect))
            lock.unlock()

            win.reCompositeImage(dirtyregion.boundingRect())
Esempio n. 2
0
	def compositeFromCorner(self,image,x,y,compmode,clippath=None,lock=None,refreshimage=True,opacity=1):
		x=int(x)
		y=int(y)
		#print "calling compositeFromCorner with args:",x,y

		if not lock:
			lock=qtcore.QWriteLocker(self.imagelock)

		width=image.size().width()
		height=image.size().height()
		rect=qtcore.QRect(x,y,width,height)
		painter=qtgui.QPainter()
		painter.begin(self.image)
		if clippath:
			painter.setClipPath(clippath)
		#print "inside compositeFromCorner"
		painter.setCompositionMode(compmode)
		painter.setOpacity(opacity)
		#painter.setRenderHint(qtgui.QPainter.HighQualityAntialiasing)
		painter.drawImage(rect,image)
		painter.end()

		dirtyregion=qtgui.QRegion(rect)
		win=BeeApp().master.getWindowById(self.windowid)

		sizelock=qtcore.QReadLocker(win.docsizelock)
		# not every type of window actually has a full image representation so just calculate what the image rectangle would be
		imagerect=qtcore.QRect(0,0,win.docwidth,win.docheight)

		if refreshimage:
			dirtyregion=dirtyregion.intersect(qtgui.QRegion(imagerect))
			lock.unlock()

			win.reCompositeImage(dirtyregion.boundingRect())