def imprint(self, cr, xSz, ySz):
'''
xSz, ySz: Size of the canvas on which imprint has to be made.
'''
#Create Source
y, x = self.pos_.y_asint(), self.pos_.x_asint()
srcIm = np.zeros((ySz, xSz, 4), dtype=np.uint8)
#print "pos: (%f, %f), sz:(%f, %f)" % (x, y, self.imSzX_, self.imSzY_)
srcIm[y : y + self.imSzY_, x : x + self.imSzX_,:] = self.data_.im[:]
surface = cairo.ImageSurface.create_for_data(srcIm,
cairo.FORMAT_ARGB32, xSz, ySz)
cr.set_source_surface(surface)
#Create Mask
pt1, pt2, pt3, pt4 = self.pts_
cr.move_to(pt1.x(), pt1.y())
cr.line_to(pt2.x(), pt2.y())
cr.line_to(pt3.x(), pt3.y())
cr.line_to(pt4.x(), pt4.y())
cr.line_to(pt1.x(), pt1.y())
#Fill source into the mask
cr.fill()
评论列表
文章目录