Ejemplo n.º 1
0
def do_grayscale(doc):
    for idata in ["LineX", "Cross", "InvertedEllipseC", "Rhomboid"]:
        do_generic(doc, globals()[idata+'_d'], jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - " + idata)

    cfg = default_cfg().add(from_file=True)
    do_generic(doc, LineX_d, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - LineX (from file)", cfg)

    cfg = default_cfg().add(img_dim = g_alt_img_dim)
    do_generic(doc, LineY_d_alt, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - %dx%d" % g_alt_img_dim, cfg)

    cfg = default_cfg().add(bits_a = 6*[16], spec_fn = gamma_fn())
    do_generic(doc, LineY_d, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - gamma",  cfg)

    cfg = default_cfg().add(dpi=(144,144))
    do_generic(doc, LineY_d, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - 144 dpi",  cfg)

    cfg = default_cfg().add(bits_a = 6*[16], spec_fn = decode_fn(1))
    do_generic(doc, Cross_d, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - decode",  cfg)

    alt_img_id, desc = get_img_id(doc, Cross_d, 16, 1, jagpdf.CS_DEVICE_GRAY)
    cfg = default_cfg().add(bits_a = 2*[16], spec_fn = alternate_fn(doc, alt_img_id))
    do_generic(doc, LineX_d, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - alternate for print",  cfg)

    Cross_d_low = imagemanip.image(imagemanip.Cross, 18, 18)
    cfg = default_cfg().add(bits_a = 2*[16], dpi=(18,18), spec_fn = interpolate_fn(), img_dim = (18,18))
    do_generic(doc, Cross_d_low, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - interpolate",  cfg)

    cfg = default_cfg().add(bits_a = 6*[8], spec_fn = color_key_mask8_fn(1))
    do_generic(doc, LineX_d, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - color key mask",  cfg)

    cfg = default_cfg().add(bits_a = 4*[8], spec_fn = hard_mask_fn())
    do_generic(doc, Cross_d, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - hard mask",  cfg)
Ejemplo n.º 2
0
 def set_doc(self, doc):
     self.dim = 64, 64
     self.doc = doc
     self.registry = {}
     generic = imagemanip.image(imagemanip.InvertedEllipseC, *self.dim)
     self.mask_data = imagemanip.pack_bits(generic, 1, 1, *self.dim)
     self.req_nr = 0
     self.test_errors()
Ejemplo n.º 3
0
 def set_doc(self, doc):
     self.dim = 64, 64
     self.doc = doc
     self.registry = {}
     generic = imagemanip.image(imagemanip.InvertedEllipseC, *self.dim)
     self.mask_data = imagemanip.pack_bits(generic, 1, 1, *self.dim)
     self.req_nr = 0
     self.test_errors()
Ejemplo n.º 4
0
 def set_doc(self, doc):
     self.dim = g_img_dim # the same because of matte
     self.doc = doc
     self.registry = {}
     self.src_img_registry = {}
     self.generic = imagemanip.image(imagemanip.LineX, *self.dim)
     self.test_errors()
     self.req_nr = 0
Ejemplo n.º 5
0
def do_masks_page(doc):
    def reg_spec(doc, meth_str, *args):
        spec = doc.image_definition()
        spec.format(jagpdf.IMAGE_FORMAT_PNG)
        spec.file_name(g_png_file)
        if meth_str:
            meth = getattr(spec, meth_str)
            meth(*args)
        return doc.image_load(spec)

    media = 9.3 * 72, 10 * 72
    doc.page_start(*media)
    paint_background(doc, media)

    page = doc.page().canvas()
    page.text_font(g_font(10))
    placer = imagemanip.ImageGrid(doc, (10, 10), 2, (4.5 * 72, 4.5 * 72), 12,
                                  5)
    placer(reg_spec(doc, None), "original (with alpha channel)")

    mask_dim = 72, 72
    gimg = imagemanip.image(imagemanip.InvertedEllipseC, *mask_dim)
    smspec = doc.define_image_mask()
    smspec.data(imagemanip.pack_bits(gimg, 8, 1, *mask_dim))
    smspec.dimensions(*mask_dim)
    smspec.bit_depth(8)
    smid = doc.register_image_mask(smspec)
    placer(reg_spec(doc, "image_mask", smid), "custom soft mask")
    placer(reg_spec(doc, "color_key_mask", [0, 127, 0, 127, 0, 255]),
           "color key mask")
    gimg = imagemanip.image(imagemanip.InvertedEllipseC, *mask_dim)

    smspec = doc.define_image_mask()
    smspec.data(imagemanip.pack_bits(gimg, 1, 1, *mask_dim))
    smspec.dimensions(*mask_dim)
    smspec.bit_depth(1)
    smid = doc.register_image_mask(smspec)
    placer(reg_spec(doc, "image_mask", smid), "custom mask")
    doc.page_end()
Ejemplo n.º 6
0
def do_masks_page(doc):
    def reg_spec(doc, meth_str, *args):
        spec = doc.image_definition()
        spec.format(jagpdf.IMAGE_FORMAT_PNG)
        spec.file_name(g_png_file)
        if meth_str:
            meth = getattr(spec, meth_str)
            meth(*args)
        return doc.image_load(spec)

    media = 9.3*72, 10*72
    doc.page_start(*media)
    paint_background(doc, media)

    page = doc.page().canvas()
    page.text_font(g_font(10))
    placer = imagemanip.ImageGrid(doc, (10,10), 2, (4.5*72,4.5*72), 12, 5)
    placer(reg_spec(doc, None), "original (with alpha channel)")

    mask_dim = 72, 72
    gimg = imagemanip.image(imagemanip.InvertedEllipseC, *mask_dim)
    smspec = doc.define_image_mask()
    smspec.data(imagemanip.pack_bits(gimg, 8, 1, *mask_dim))
    smspec.dimensions(*mask_dim)
    smspec.bit_depth(8)
    smid = doc.register_image_mask(smspec)
    placer(reg_spec(doc, "image_mask", smid), "custom soft mask")
    placer(reg_spec(doc, "color_key_mask", [0,127,0,127,0,255]), "color key mask")
    gimg = imagemanip.image(imagemanip.InvertedEllipseC, *mask_dim)

    smspec = doc.define_image_mask()
    smspec.data(imagemanip.pack_bits(gimg, 1, 1, *mask_dim))
    smspec.dimensions(*mask_dim)
    smspec.bit_depth(1)
    smid = doc.register_image_mask(smspec)
    placer(reg_spec(doc, "image_mask", smid), "custom mask")
    doc.page_end()
Ejemplo n.º 7
0
def do_grayscale(doc):
    for idata in ["LineX", "Cross", "InvertedEllipseC", "Rhomboid"]:
        do_generic(doc,
                   globals()[idata + '_d'], jagpdf.CS_DEVICE_GRAY, 1,
                   "GRAYSCALE - " + idata)

    cfg = default_cfg().add(from_file=True)
    do_generic(doc, LineX_d, jagpdf.CS_DEVICE_GRAY, 1,
               "GRAYSCALE - LineX (from file)", cfg)

    cfg = default_cfg().add(img_dim=g_alt_img_dim)
    do_generic(doc, LineY_d_alt, jagpdf.CS_DEVICE_GRAY, 1,
               "GRAYSCALE - %dx%d" % g_alt_img_dim, cfg)

    cfg = default_cfg().add(bits_a=6 * [16], spec_fn=gamma_fn())
    do_generic(doc, LineY_d, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - gamma",
               cfg)

    cfg = default_cfg().add(dpi=(144, 144))
    do_generic(doc, LineY_d, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - 144 dpi",
               cfg)

    cfg = default_cfg().add(bits_a=6 * [16], spec_fn=decode_fn(1))
    do_generic(doc, Cross_d, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - decode",
               cfg)

    alt_img_id, desc = get_img_id(doc, Cross_d, 16, 1, jagpdf.CS_DEVICE_GRAY)
    cfg = default_cfg().add(bits_a=2 * [16],
                            spec_fn=alternate_fn(doc, alt_img_id))
    do_generic(doc, LineX_d, jagpdf.CS_DEVICE_GRAY, 1,
               "GRAYSCALE - alternate for print", cfg)

    Cross_d_low = imagemanip.image(imagemanip.Cross, 18, 18)
    cfg = default_cfg().add(bits_a=2 * [16],
                            dpi=(18, 18),
                            spec_fn=interpolate_fn(),
                            img_dim=(18, 18))
    do_generic(doc, Cross_d_low, jagpdf.CS_DEVICE_GRAY, 1,
               "GRAYSCALE - interpolate", cfg)

    cfg = default_cfg().add(bits_a=6 * [8], spec_fn=color_key_mask8_fn(1))
    do_generic(doc, LineX_d, jagpdf.CS_DEVICE_GRAY, 1,
               "GRAYSCALE - color key mask", cfg)

    cfg = default_cfg().add(bits_a=4 * [8], spec_fn=hard_mask_fn())
    do_generic(doc, Cross_d, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE - hard mask",
               cfg)
Ejemplo n.º 8
0
    return id_, desc


def do_generic(doc, image, cs, nr_channels, title, p = default_cfg()):
    page_dim = 4.8*72, 3.8*72
    page, grid, placer = prepare_page(doc, page_dim)
    for bpc in p.bits_a:
        img, desc = get_img_id(doc, image, bpc, nr_channels, cs, p)
        placer(img, desc, *grid.next())

    page.text_font(g_font(14))
    page.text(20, page_dim[1] - 30, title)
    doc.page_end()

###########################################################################
LineX_d            = imagemanip.image(imagemanip.LineX, *g_img_dim)
LineY_d            = imagemanip.image(imagemanip.LineY, *g_img_dim)
InvertedEllipseC_d = imagemanip.image(imagemanip.InvertedEllipseC, *g_img_dim)
Rhomboid_d         = imagemanip.image(imagemanip.Rhomboid, *g_img_dim)
Cross_d            = imagemanip.image(imagemanip.Cross, *g_img_dim)
Checkboard_d       = [(x%4 in [0,1] and y%4 in [0,1]) and 1 or 0 for x,y in imagemanip.grid_coords(*g_img_dim)]

LineX_d_alt            = imagemanip.image(imagemanip.LineX, *g_alt_img_dim)
LineY_d_alt            = imagemanip.image(imagemanip.LineY, *g_alt_img_dim)
InvertedEllipseC_d_alt = imagemanip.image(imagemanip.InvertedEllipseC, *g_alt_img_dim)
Rhomboid_d_alt         = imagemanip.image(imagemanip.Rhomboid, *g_alt_img_dim)
Cross_d_alt            = imagemanip.image(imagemanip.Cross, *g_alt_img_dim)


#odd mask goes through file, even through memory
class HardMask:
Ejemplo n.º 9
0

def do_generic(doc, image, cs, nr_channels, title, p=default_cfg()):
    page_dim = 4.8 * 72, 3.8 * 72
    page, grid, placer = prepare_page(doc, page_dim)
    for bpc in p.bits_a:
        img, desc = get_img_id(doc, image, bpc, nr_channels, cs, p)
        placer(img, desc, *grid.next())

    page.text_font(g_font(14))
    page.text(20, page_dim[1] - 30, title)
    doc.page_end()


###########################################################################
LineX_d = imagemanip.image(imagemanip.LineX, *g_img_dim)
LineY_d = imagemanip.image(imagemanip.LineY, *g_img_dim)
InvertedEllipseC_d = imagemanip.image(imagemanip.InvertedEllipseC, *g_img_dim)
Rhomboid_d = imagemanip.image(imagemanip.Rhomboid, *g_img_dim)
Cross_d = imagemanip.image(imagemanip.Cross, *g_img_dim)
Checkboard_d = [(x % 4 in [0, 1] and y % 4 in [0, 1]) and 1 or 0
                for x, y in imagemanip.grid_coords(*g_img_dim)]

LineX_d_alt = imagemanip.image(imagemanip.LineX, *g_alt_img_dim)
LineY_d_alt = imagemanip.image(imagemanip.LineY, *g_alt_img_dim)
InvertedEllipseC_d_alt = imagemanip.image(imagemanip.InvertedEllipseC,
                                          *g_alt_img_dim)
Rhomboid_d_alt = imagemanip.image(imagemanip.Rhomboid, *g_alt_img_dim)
Cross_d_alt = imagemanip.image(imagemanip.Cross, *g_alt_img_dim)

Ejemplo n.º 10
0
                                        (8, 0, nr_channels*(.5,), None),\
                                        (8, 0, nr_channels*(.75,), None),\
                                        (8, 0, nr_channels*(1,), None)]\
                     }[test_type]

    def __call__(self, spec):
        val = self.val.pop()
        if val:
            spec.image_mask(g_softmask.id(*val))
            matte_str = val[2] and str(val[2][0]) or "-"
            return "bits: %d, i: %s, m:%s, d:%s" % (val[0], val[1] and "yes" or "no", matte_str, str(val[3]))
        return "No mask."



LineX_d            = imagemanip.image(imagemanip.LineX, *g_img_dim)
LineY_d            = imagemanip.image(imagemanip.LineY, *g_img_dim)
Rhomboid_d         = imagemanip.image(imagemanip.Rhomboid, *g_img_dim)
InvertedCross_d    = imagemanip.image(imagemanip.InvertedCross, *g_img_dim)
Checkboard_d       = tuple([(x%2 in [0] and y%2 in [0]) and 1 or 0 for x,y in imagemanip.grid_coords(*g_img_dim)])


def do_grayscale(doc):
    do_page_for_cs(doc, Checkboard_d, jagpdf.CS_DEVICE_GRAY, 1, "GRAYSCALE", default_cfg())

def do_rgb(doc):
    channels = [LineX_d, LineY_d, Rhomboid_d]
    generic_image = imagemanip.interleave_channels(*channels)
    do_page_for_cs(doc, generic_image, jagpdf.CS_DEVICE_RGB, 3, "RGB", default_cfg())