def render_image(self, ctx, obj): canvas_matrix = ctx.get_matrix() canvas_trafo = libcairo.get_trafo_from_matrix(canvas_matrix) zoom = canvas_trafo[0] h = obj.size[1] lu_corner = libgeom.apply_trafo_to_point([0.0, float(h)], obj.trafo) x0, y0 = libgeom.apply_trafo_to_point(lu_corner, canvas_trafo) m11, m12, m21, m22 = obj.trafo[:4] matrix = cairo.Matrix(zoom * m11, -zoom * m12, -zoom * m21, zoom * m22, x0, y0) ctx.set_matrix(matrix) if self.contour_flag: if not obj.cache_gray_cdata: libimg.update_gray_image(self.cms, obj) ctx.set_source_surface(obj.cache_gray_cdata) if zoom * abs(m11) > .98: ctx.get_source().set_filter(cairo.FILTER_NEAREST) ctx.paint_with_alpha(0.3) else: ctx.set_source_surface(self.get_image(obj)) if zoom * abs(m11) > .98: ctx.get_source().set_filter(cairo.FILTER_NEAREST) ctx.paint() ctx.set_matrix(canvas_matrix)
def render_image(self, ctx, obj): if not obj.cache_cdata: libimg.update_image(self.cms, obj) canvas_matrix = ctx.get_matrix() canvas_trafo = libcairo.get_trafo_from_matrix(canvas_matrix) zoom = canvas_trafo[0] h = obj.size[1] lu_corner = libgeom.apply_trafo_to_point([0.0, float(h)], obj.trafo) x0, y0 = libgeom.apply_trafo_to_point(lu_corner, canvas_trafo) m11, m12, m21, m22 = obj.trafo[:4] matrix = cairo.Matrix(zoom * m11, -zoom * m12, - zoom * m21, zoom * m22, x0, y0) ctx.set_matrix(matrix) if self.contour_flag: if not obj.cache_gray_cdata: libimg.update_gray_image(self.cms, obj) ctx.set_source_surface(obj.cache_gray_cdata) if zoom * abs(m11) > .98: ctx.get_source().set_filter(cairo.FILTER_NEAREST) ctx.paint_with_alpha(0.3) else: ctx.set_source_surface(obj.cache_cdata) if zoom * abs(m11) > .98: ctx.get_source().set_filter(cairo.FILTER_NEAREST) ctx.paint() ctx.set_matrix(canvas_matrix)
def _create_pattern_image(self, obj, force_proofing=False, gray=False): fill = obj.style[0] pattern_fill = fill[2] bmpstr = b64decode(pattern_fill[1]) image_obj = sk2_model.Pixmap(obj.config) libimg.set_image_data(self.cms, image_obj, bmpstr) libimg.flip_top_to_bottom(image_obj) if pattern_fill[0] == sk2const.PATTERN_IMG and len(pattern_fill) > 2: image_obj.style[3] = deepcopy(pattern_fill[2]) if gray: libimg.update_gray_image(self.cms, image_obj) else: libimg.update_image(self.cms, image_obj, force_proofing) return image_obj
def get_image(self, pixmap): if self.colorspace == uc2const.COLOR_RGB: if not pixmap.cache_cdata: proofing = self.cms.proofing self.cms.proofing = False libimg.update_image(self.cms, pixmap) self.cms.proofing = proofing return pixmap.cache_cdata elif self.colorspace == uc2const.COLOR_CMYK: if not pixmap.cache_ps_cdata: libimg.update_image(self.cms, pixmap, True) pixmap.cache_ps_cdata = pixmap.cache_cdata pixmap.cache_cdata = None return pixmap.cache_ps_cdata else: if not pixmap.cache_gray_cdata: libimg.update_gray_image(self.cms, pixmap) return pixmap.cache_gray_cdata