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; 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 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->Compression = compr; return code; }
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; }
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; bool write_datetime = tfdev->write_datetime; 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 switch (code = param_read_bool(plist, (param_name = "TIFFDateTime"), &write_datetime)) { 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, 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; }