def transform_pixbuf(p, dest_size, scale): dest = Pixbuf(p.props.colorspace, p.props.has_alpha, p.props.bits_per_sample, dest_size, dest_size) dest.fill(0) s = dest_size * scale / max(p.get_width(), p.get_height()) offset_x = int(round((dest_size - p.get_width() * s) / 2)) offset_y = int(round((dest_size - p.get_height() * s) / 2)) dest_width = int(round(min(dest_size-offset_x, s*p.get_width()))) dest_height = int(round(min(dest_size-offset_y, s*p.get_height()))) p.scale(dest, offset_x, offset_y, dest_width, dest_height, offset_x, offset_y, s, s, INTERP_HYPER) return dest
def transform_pixbuf(p, dest_size, scale): dest = Pixbuf(p.props.colorspace, p.props.has_alpha, p.props.bits_per_sample, dest_size, dest_size) dest.fill(0) s = dest_size * scale / max(p.get_width(), p.get_height()) offset_x = int(round((dest_size - p.get_width() * s) / 2)) offset_y = int(round((dest_size - p.get_height() * s) / 2)) dest_width = int(round(min(dest_size - offset_x, s * p.get_width()))) dest_height = int(round(min(dest_size - offset_y, s * p.get_height()))) p.scale(dest, offset_x, offset_y, dest_width, dest_height, offset_x, offset_y, s, s, INTERP_HYPER) return dest
def create_blank_pixbuf(size=16): pix = Pixbuf(COLORSPACE_RGB, True, 8, size, size) pix.fill(0x0) return pix