Пример #1
0
static int
pngalpha_put_params(gx_device * pdev, gs_param_list * plist)
{
    gx_device_pngalpha *ppdev = (gx_device_pngalpha *)pdev;
    int background;
    int code;

    /* BackgroundColor in format 16#RRGGBB is used for bKGD chunk */
    switch(code = param_read_int(plist, "BackgroundColor", &background)) {
	case 0:
	    ppdev->background = background & 0xffffff;
	    break;
	case 1:		/* not found */
	    code = 0;
	    break;
	default:
	    param_signal_error(plist, "BackgroundColor", code);
	    break;
    }

    if (code == 0) {
	code = gdev_prn_put_params(pdev, plist);
	if ((ppdev->procs.fill_rectangle != pngalpha_fill_rectangle) &&
	    (ppdev->procs.fill_rectangle != NULL)) {
	    /* Get current implementation of fill_rectangle and restore ours.
	     * Implementation is either clist or memory and can change 
	     * during put_params.
	     */
	    ppdev->orig_fill_rectangle = ppdev->procs.fill_rectangle;
	    ppdev->procs.fill_rectangle = pngalpha_fill_rectangle;
	}
    }
    return code;
}
Пример #2
0
static int
fpng_put_params(gx_device *dev, gs_param_list *plist)
{
    gx_device_fpng *pdev = (gx_device_fpng *)dev;
    int code, ecode;
    int dsf = pdev->downscale_factor;
    const char *param_name;

    ecode = 0;
    switch (code = param_read_int(plist, (param_name = "DownScaleFactor"), &dsf)) {
        case 0:
            if (dsf >= 1)
                break;
            code = gs_error_rangecheck;
        default:
            ecode = code;
            param_signal_error(plist, param_name, ecode);
        case 1:
            break;
    }

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

    pdev->downscale_factor = dsf;

    return ecode;
}
Пример #3
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;
}
Пример #4
0
/* before the device is opened */
int
os2prn_put_params(gx_device * dev, gs_param_list * plist)
{
    int ecode = 0, code;
    int old_bpp = dev->color_info.depth;
    int bpp = old_bpp;
    gs_param_string qs;

    /* Handle extra parameters */
    switch (code = param_read_string(plist, "OS2QUEUE", &qs)) {
	case 0:
	    if (qs.size == strlen(opdev->queue_name) &&
		!memcmp(opdev->queue_name, qs.data, qs.size)
		) {
		qs.data = 0;
		break;
	    }
	    if (dev->is_open)
		ecode = gs_error_rangecheck;
	    else if (qs.size >= sizeof(opdev->queue_name))
		ecode = gs_error_limitcheck;
	    else
		break;
	    goto qe;
	default:
	    ecode = code;
	  qe:param_signal_error(plist, "OS2QUEUE", ecode);
	case 1:
	    qs.data = 0;
	    break;
    }

    switch (code = param_read_int(plist, "BitsPerPixel", &bpp)) {
	case 0:
	    if (dev->is_open)
		ecode = gs_error_rangecheck;
	    else {		/* change dev->color_info is valid before device is opened */
		os2prn_set_bpp(dev, bpp);
		break;
	    }
	    goto bppe;
	default:
	    ecode = code;
	  bppe:param_signal_error(plist, "BitsPerPixel", ecode);
	case 1:
	    break;
    }

    if (ecode >= 0)
	ecode = gdev_prn_put_params(dev, plist);

    if ((ecode >= 0) && (qs.data != 0)) {
	memcpy(opdev->queue_name, qs.data, qs.size);
	opdev->queue_name[qs.size] = 0;
    }
    return ecode;
}
Пример #5
0
int
gdev_prn_put_params_planar(gx_device * pdev, gs_param_list * plist,
			   bool *pupb)
{
    bool upb = *pupb;
    int ecode = 0, code;

    if (pdev->color_info.num_components > 1)
	ecode = param_read_bool(plist, "UsePlanarBuffer", &upb);
    code = gdev_prn_put_params(pdev, plist);
    if (ecode >= 0)
	ecode = code;
    if (ecode >= 0)
	*pupb = upb;
    return ecode;
}
Пример #6
0
static int
hpjet_put_params(gx_device *pdev, gs_param_list *plist)
{
    gx_device_hpjet *dev = (gx_device_hpjet *)pdev;
    int code;
    bool ManualFeed;
    bool ManualFeed_set = false;
    int MediaPosition;
    bool MediaPosition_set = false;
    bool Tumble;

    code = param_read_bool(plist, "ManualFeed", &ManualFeed);
    if (code == 0) ManualFeed_set = true;
    if (code >= 0) {
        code = param_read_int(plist, "MediaPosition", &MediaPosition);
        if (code == 0) MediaPosition_set = true;
        else if (code < 0) {
            if (param_read_null(plist, "MediaPosition") == 0) {
                code = 0;
            }
        }
    }
    if (code>=0)
    {
       code=param_read_bool(plist,"Tumble",&Tumble);
       if (code != 0) Tumble = false; /* default: no tumble */
    }

    if (code >= 0)
        code = gdev_prn_put_params(pdev, plist);

    if (code >= 0) {
    dev->Tumble=Tumble;
        if (ManualFeed_set) {
            dev->ManualFeed = ManualFeed;
            dev->ManualFeed_set = true;
        }
        if (MediaPosition_set) {
            dev->MediaPosition = MediaPosition;
            dev->MediaPosition_set = true;
        }
    }

    return code;
}
Пример #7
0
static int
ds32_put_params_downscale_cmyk(gx_device * dev, gs_param_list * plist)
{
    gx_device_ds32 *const dsdev = (gx_device_ds32 *)dev;
    int code, ecode;

    code = gx_downscaler_read_params(plist, &dsdev->downscale,
                                     (GX_DOWNSCALER_PARAMS_MFS |
                                      GX_DOWNSCALER_PARAMS_TRAP));
    if (code < 0)
    {
        ecode = code;
    }
    if (ecode < 0)
        return ecode;
    code = gdev_prn_put_params(dev, plist);
    return code;
}
Пример #8
0
static int
tiff_put_some_params(gx_device * dev, gs_param_list * plist, int which)
{
    gx_device_tiff *const tfdev = (gx_device_tiff *)dev;
    int ecode = 0;
    int code;
    const char *param_name;
    bool big_endian = tfdev->BigEndian;
    uint16 compr = tfdev->Compression;
    gs_param_string comprstr;
    long downscale = tfdev->DownScaleFactor;
    long mss = tfdev->MaxStripSize;
    long aw = tfdev->AdjustWidth;
    long mfs = tfdev->MinFeatureSize;

    /* 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 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, (which & 1 ? 1 : dev->color_info.depth)))
            {
                errprintf(tfdev->memory,
                          (ecode < 0 ? "Unknown compression setting\n" :
                           "Invalid compression setting for this bitdepth\n"));
                param_signal_error(plist, param_name, ecode);
            }
            break;
        case 1:
            break;
        default:
            ecode = code;
            param_signal_error(plist, param_name, ecode);
    }
    /* Read Downscale factor */
    if (which & 1) {
        switch (code = param_read_long(plist,
                                       (param_name = "DownScaleFactor"),
                                       &downscale)) {
            case 0:
                if (downscale <= 0)
                    downscale = 1;
                break;
            case 1:
                break;
            default:
                ecode = code;
                param_signal_error(plist, param_name, ecode);
        }
    }
    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;
    }
    switch (code = param_read_long(plist, (param_name = "AdjustWidth"), &aw)) {
        case 0:
            if (aw >= 0)
                break;
            code = gs_error_rangecheck;
        default:
            ecode = code;
            param_signal_error(plist, param_name, ecode);
        case 1:
            break;
    }
    switch (code = param_read_long(plist, (param_name = "MinFeatureSize"), &mfs)) {
        case 0:
            if ((mfs >= 0) && (mfs <= 4))
                break;
            code = gs_error_rangecheck;
        default:
            ecode = code;
            param_signal_error(plist, param_name, ecode);
        case 1:
            break;
    }

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

    tfdev->BigEndian = big_endian;
    tfdev->Compression = compr;
    tfdev->MaxStripSize = mss;
    tfdev->DownScaleFactor = downscale;
    tfdev->AdjustWidth = aw;
    tfdev->MinFeatureSize = mfs;
    return code;
}
Пример #9
0
/* before the device is opened */
int
win_pr2_put_params(gx_device * pdev, gs_param_list * plist)
{
    int ecode = 0, code;
    int old_bpp = pdev->color_info.depth;
    int bpp = old_bpp;
    bool tumble   = wdev->tumble;
    bool nocancel = wdev->nocancel;
    int queryuser = 0;
    bool old_duplex = wdev->Duplex;
    bool old_tumble = wdev->tumble;
    int  old_orient = wdev->user_orient;
    int  old_color  = wdev->user_color;
    int  old_paper  = wdev->user_paper;
    int  old_mx_dpi = wdev->max_dpi;

    if (wdev->Duplex_set < 0) {
	wdev->Duplex_set = 0;
	wdev->Duplex = false;
	wdev->tumble = false;
    }
    
    win_pr2_copy_check(wdev);

    code = win_pr2_read_user_settings(wdev, plist);

    switch (code = param_read_int(plist, "BitsPerPixel", &bpp)) {
	case 0:
	    if (pdev->is_open) {
		if (wdev->selected_bpp == bpp) {
		    break;
		}
		ecode = gs_error_rangecheck;
	    } else {		/* change dev->color_info is valid before device is opened */
		win_pr2_set_bpp(pdev, bpp);
		break;
	    }
	    goto bppe;
	default:
	    ecode = code;
	  bppe:param_signal_error(plist, "BitsPerPixel", ecode);
	case 1:
	    break;
    }

    switch (code = param_read_bool(plist, "NoCancel", &nocancel)) {
	case 0:
	    if (pdev->is_open) {
		if (wdev->nocancel == nocancel) {
		    break;
		}
		ecode = gs_error_rangecheck;
	    } else {
		wdev->nocancel = nocancel;
		break;
	    }
	    goto nocancele;
	default:
	    ecode = code;
	  nocancele:param_signal_error(plist, "NoCancel", ecode);
	case 1:
	    break;
    }

    switch (code = param_read_bool(plist, "Tumble", &tumble)) {
	case 0:
	    wdev->tumble = tumble;
	    break;
	default:
	    ecode = code;
	    param_signal_error(plist, "Tumble", ecode);
	case 1:
	    break;
    }

    switch (code = param_read_int(plist, "QueryUser", &queryuser)) {
	case 0:
	    if ((queryuser > 0) &&
		(queryuser < 4)) {
		win_pr2_print_setup_interaction(wdev, queryuser);
	    }
	    break;
	default:
	    ecode = code;
	    param_signal_error(plist, "QueryUser", ecode);
	case 1:
	    break;
    }

    if (ecode >= 0)
	ecode = gdev_prn_put_params(pdev, plist);
    
    if (wdev->win32_hdevmode && wdev->hdcprn) {
	if ( (old_duplex != wdev->Duplex)
	  || (old_tumble != wdev->tumble)
	  || (old_orient != wdev->user_orient)
	  || (old_color  != wdev->user_color)
	  || (old_paper  != wdev->user_paper)
	  || (old_mx_dpi != wdev->max_dpi) ) {
	    
	    LPDEVMODE pdevmode = GlobalLock(wdev->win32_hdevmode);
	    
	    if (pdevmode) {
		win_pr2_update_win(wdev, pdevmode);
		ResetDC(wdev->hdcprn, pdevmode);
		GlobalUnlock(pdevmode);
	    }
	}
    }
    
    return ecode;
}