예제 #1
0
/* we call this from ps code to instantiate a jbig2_global_context
   object which the JBIG2Decode filter uses if available. The
   pointer to the global context is stored in an astruct object
   and returned that way since it lives outside the interpreters
   memory management */
static int
z_jbig2makeglobalctx(i_ctx_t * i_ctx_p)
{
        void *global = NULL;
        s_jbig2_global_data_t *st;
        os_ptr op = osp;
        byte *data;
        int size;
        int code = 0;

        check_type(*op, t_astruct);
        size = gs_object_size(imemory, op->value.pstruct);
        data = r_ptr(op, byte);

        code = s_jbig2decode_make_global_data(data, size,
                        &global);
        if (size > 0 && global == NULL) {
            dmlprintf(imemory, "failed to create parsed JBIG2GLOBALS object.");
            return_error(gs_error_unknownerror);
        }

        st = ialloc_struct(s_jbig2_global_data_t,
                &st_jbig2_global_data_t,
                "jbig2decode parsed global context");
        if (st == NULL) return_error(gs_error_VMerror);

        st->data = global;
        make_astruct(op, a_readonly | icurrent_space, (byte*)st);

        return code;
}
예제 #2
0
static int
perm_put_params(gx_device *pdev, gs_param_list *plist)
{
    gx_device_perm_t * const dev = (gx_device_perm_t *)pdev;
    gx_device_color_info save_info;
    int code;
    int new_permute = dev->permute;
    int new_mode = dev->mode;

    code = param_read_int(plist, "Permute", &new_permute);
    if (code < 0)
        return code;
    code = param_read_int(plist, "Mode", &new_mode);
    if (code < 0)
        return code;
    if (new_mode < 0 || new_mode >= sizeof(perm_cmapping_procs) / sizeof(perm_cmapping_procs[0])) {
        dmlprintf(pdev->memory, "rangecheck!\n");
        return_error(gs_error_rangecheck);
    }
    dev->permute = new_permute;
    dev->mode = new_mode;
    save_info = pdev->color_info;
    code = perm_set_color_model(dev, dev->mode, dev->permute);
    if (code >= 0)
        code = gdev_prn_put_params(pdev, plist);
    if (code < 0)
        pdev->color_info = save_info;
    return code;
}
예제 #3
0
static void do_device_dump(gx_device *dev, int n)
{
    int i, ret;
    gxdso_device_child_request data;

    /* Dump the details of device dev */
    for (i = 0; i < n; i++)
        dmlprintf(dev->memory, " ");
    if (dev == NULL) {
        dmlprintf(dev->memory, "NULL\n");
        return;
    }
    dmlprintf3(dev->memory, "%p(%ld) = '%s'\n", dev, dev->rc.ref_count, dev->dname);

    data.n = 0;
    do {
        data.target = dev;
        ret = dev_proc(dev, dev_spec_op)(dev, gxdso_device_child, &data, sizeof(data));
        if (ret > 0)
            do_device_dump(data.target, n+1);
    } while ((ret > 0) && (data.n != 0));
}
예제 #4
0
파일: gdevtfax.c 프로젝트: hackqiang/gs
static int
tfax_put_params(gx_device * dev, gs_param_list * plist)
{
    gx_device_tfax *const tfdev = (gx_device_tfax *)dev;
    int ecode = 0;
    int code;
    long mss = tfdev->MaxStripSize;
    int fill_order = tfdev->FillOrder;
    const char *param_name;
    bool big_endian = tfdev->BigEndian;
    bool usebigtiff = tfdev->UseBigTIFF;
    uint16 compr = tfdev->Compression;
    gs_param_string comprstr;

    switch (code = param_read_long(plist, (param_name = "MaxStripSize"), &mss)) {
        case 0:
            /*
             * Strip must be large enough to accommodate a raster line.
             * If the max strip size is too small, we still write a single
             * line per strip rather than giving an error.
             */
            if (mss >= 0)
                break;
            code = gs_error_rangecheck;
        default:
            ecode = code;
            param_signal_error(plist, param_name, ecode);
        case 1:
            break;
    }

    /* Following TIFF spec, FillOrder is integer */
    switch (code = param_read_int(plist, (param_name = "FillOrder"), &fill_order)) {
        case 0:
            if (fill_order == 1 || fill_order == 2)
                break;
            code = gs_error_rangecheck;
        default:
            ecode = code;
            param_signal_error(plist, param_name, ecode);
        case 1:
            break;
    }

    /* Read BigEndian option as bool */
    switch (code = param_read_bool(plist, (param_name = "BigEndian"), &big_endian)) {
        default:
            ecode = code;
            param_signal_error(plist, param_name, ecode);
        case 0:
        case 1:
            break;
    }

    /* Read UseBigTIFF option as bool */
    switch (code = param_read_bool(plist, (param_name = "UseBigTiff"), &usebigtiff)) {
        default:
            ecode = code;
            param_signal_error(plist, param_name, ecode);
        case 0:
        case 1:
            break;
    }

#if !(TIFFLIB_VERSION >= 20111221)
    if (usebigtiff)
        dmlprintf(dev->memory, "Warning: this version of libtiff does not support BigTIFF, ignoring parameter\n");
    usebigtiff = false;
#endif

    /* Read Compression */
    switch (code = param_read_string(plist, (param_name = "Compression"), &comprstr)) {
        case 0:
            if ((ecode = tiff_compression_id(&compr, &comprstr)) < 0 ||
                !tiff_compression_allowed(compr, dev->color_info.depth))
                param_signal_error(plist, param_name, ecode);
            break;
        case 1:
            break;
        default:
            ecode = code;
            param_signal_error(plist, param_name, ecode);
    }

    if (ecode < 0)
        return ecode;
    code = gdev_fax_put_params(dev, plist);
    if (code < 0)
        return code;

    tfdev->MaxStripSize = mss;
    tfdev->FillOrder = fill_order;
    tfdev->BigEndian = big_endian;
    tfdev->UseBigTIFF = usebigtiff;
    tfdev->Compression = compr;
    return code;
}