kopia lustrzana https://gitlab.com/sane-project/backends
brother_mfp: Added preview option.
Also fixed some warnings that affected the pipeline.brother_mfp_backend
rodzic
a484c6ad93
commit
76481920c3
|
@ -399,7 +399,6 @@ class BrotherEncoderFamily2 : public BrotherEncoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BrotherEncoderFamily2(SANE_Word capabilities):
|
BrotherEncoderFamily2(SANE_Word capabilities):
|
||||||
capabilities(capabilities),
|
|
||||||
colour_decoder(capabilities)
|
colour_decoder(capabilities)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -461,7 +460,6 @@ private:
|
||||||
size_t *src_data_consumed, ScanDataHeader &header);
|
size_t *src_data_consumed, ScanDataHeader &header);
|
||||||
|
|
||||||
ScanDataHeader current_header;
|
ScanDataHeader current_header;
|
||||||
SANE_Word capabilities;
|
|
||||||
|
|
||||||
BrotherJFIFDecoder jfif_decoder;
|
BrotherJFIFDecoder jfif_decoder;
|
||||||
BrotherGrayRLengthDecoder gray_decoder;
|
BrotherGrayRLengthDecoder gray_decoder;
|
||||||
|
@ -473,7 +471,6 @@ class BrotherEncoderFamily3 : public BrotherEncoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BrotherEncoderFamily3(SANE_Word capabilities):
|
BrotherEncoderFamily3(SANE_Word capabilities):
|
||||||
capabilities(capabilities),
|
|
||||||
colour_decoder(capabilities)
|
colour_decoder(capabilities)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -535,7 +532,6 @@ private:
|
||||||
size_t *src_data_consumed, ScanDataHeader &header);
|
size_t *src_data_consumed, ScanDataHeader &header);
|
||||||
|
|
||||||
ScanDataHeader current_header;
|
ScanDataHeader current_header;
|
||||||
SANE_Word capabilities;
|
|
||||||
|
|
||||||
BrotherGrayRawDecoder gray_raw_decoder;
|
BrotherGrayRawDecoder gray_raw_decoder;
|
||||||
BrotherGrayRLengthDecoder gray_decoder;
|
BrotherGrayRLengthDecoder gray_decoder;
|
||||||
|
@ -546,9 +542,9 @@ private:
|
||||||
class BrotherEncoderFamily4 : public BrotherEncoder
|
class BrotherEncoderFamily4 : public BrotherEncoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BrotherEncoderFamily4(SANE_Word capabilities):
|
BrotherEncoderFamily4(SANE_Word capabilities)
|
||||||
capabilities(capabilities)
|
|
||||||
{
|
{
|
||||||
|
(void)capabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
~BrotherEncoderFamily4 ()
|
~BrotherEncoderFamily4 ()
|
||||||
|
@ -598,7 +594,6 @@ private:
|
||||||
size_t *src_data_consumed, ScanDataHeader &header);
|
size_t *src_data_consumed, ScanDataHeader &header);
|
||||||
|
|
||||||
ScanDataHeader current_header;
|
ScanDataHeader current_header;
|
||||||
SANE_Word capabilities;
|
|
||||||
|
|
||||||
BrotherJFIFDecoder jfif_decoder;
|
BrotherJFIFDecoder jfif_decoder;
|
||||||
BrotherGrayRLengthDecoder gray_decoder;
|
BrotherGrayRLengthDecoder gray_decoder;
|
||||||
|
|
|
@ -92,8 +92,7 @@ enum Brother_Option
|
||||||
OPT_MODE,
|
OPT_MODE,
|
||||||
OPT_X_RESOLUTION,
|
OPT_X_RESOLUTION,
|
||||||
OPT_Y_RESOLUTION,
|
OPT_Y_RESOLUTION,
|
||||||
// OPT_PREVIEW,
|
OPT_PREVIEW,
|
||||||
// OPT_ENCODING,
|
|
||||||
|
|
||||||
OPT_GEOMETRY_GROUP,
|
OPT_GEOMETRY_GROUP,
|
||||||
OPT_TL_X, /* top-left x */
|
OPT_TL_X, /* top-left x */
|
||||||
|
@ -481,6 +480,17 @@ init_options (BrotherDevice *device)
|
||||||
od->constraint.word_list = device->model->y_res_list;
|
od->constraint.word_list = device->model->y_res_list;
|
||||||
device->val[OPT_Y_RESOLUTION].w = device->model->y_res_list[1];
|
device->val[OPT_Y_RESOLUTION].w = device->model->y_res_list[1];
|
||||||
|
|
||||||
|
od = &device->opt[OPT_PREVIEW];
|
||||||
|
od->name = SANE_NAME_PREVIEW;
|
||||||
|
od->title = SANE_TITLE_PREVIEW;
|
||||||
|
od->desc = SANE_DESC_PREVIEW;
|
||||||
|
od->type = SANE_TYPE_BOOL;
|
||||||
|
od->unit = SANE_UNIT_NONE;
|
||||||
|
od->size = 1 * sizeof(SANE_Bool);
|
||||||
|
od->constraint_type = SANE_CONSTRAINT_NONE;
|
||||||
|
od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED;
|
||||||
|
device->val[OPT_PREVIEW].b = SANE_FALSE;
|
||||||
|
|
||||||
/* opt_geometry_group */
|
/* opt_geometry_group */
|
||||||
od = &device->opt[OPT_GEOMETRY_GROUP];
|
od = &device->opt[OPT_GEOMETRY_GROUP];
|
||||||
od->name = "";
|
od->name = "";
|
||||||
|
@ -590,8 +600,7 @@ init_options (BrotherDevice *device)
|
||||||
od->type = SANE_TYPE_BOOL;
|
od->type = SANE_TYPE_BOOL;
|
||||||
od->unit = SANE_UNIT_NONE;
|
od->unit = SANE_UNIT_NONE;
|
||||||
od->size = 1 * sizeof(SANE_Bool);
|
od->size = 1 * sizeof(SANE_Bool);
|
||||||
od->constraint_type = SANE_CONSTRAINT_RANGE;
|
od->constraint_type = SANE_CONSTRAINT_NONE;
|
||||||
od->constraint.range = &constraint_brightness_contrast;
|
|
||||||
if ((device->model->capabilities & CAP_MODE_HAS_JPEG)
|
if ((device->model->capabilities & CAP_MODE_HAS_JPEG)
|
||||||
&& (device->model->capabilities & CAP_MODE_HAS_RAW))
|
&& (device->model->capabilities & CAP_MODE_HAS_RAW))
|
||||||
od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED;
|
od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED;
|
||||||
|
@ -999,6 +1008,20 @@ sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action,
|
||||||
status = SANE_STATUS_GOOD;
|
status = SANE_STATUS_GOOD;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPT_PREVIEW:
|
||||||
|
if (device->val[option].b == *(SANE_Bool *) value)
|
||||||
|
{
|
||||||
|
DBG (DBG_DETAIL, "sane_control_option: option %d (%s) not changed\n",
|
||||||
|
option, device->opt[option].name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
device->val[option].b = *(SANE_Bool *) value;
|
||||||
|
DBG (DBG_DETAIL, "sane_control_option: set option %d (%s) to %s\n",
|
||||||
|
option, device->opt[option].name, *(SANE_Bool *) value? "TRUE": "FALSE");
|
||||||
|
|
||||||
|
status = SANE_STATUS_GOOD;
|
||||||
|
break;
|
||||||
|
|
||||||
case OPT_MODE:
|
case OPT_MODE:
|
||||||
if (strcmp (device->val[option].s, (SANE_String)value) == 0)
|
if (strcmp (device->val[option].s, (SANE_String)value) == 0)
|
||||||
{
|
{
|
||||||
|
@ -1082,6 +1105,12 @@ sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action,
|
||||||
option, device->opt[option].name, *(SANE_Bool *) value? "TRUE": "FALSE");
|
option, device->opt[option].name, *(SANE_Bool *) value? "TRUE": "FALSE");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPT_PREVIEW:
|
||||||
|
*(SANE_Bool *) value = device->val[option].b;
|
||||||
|
DBG (DBG_DETAIL, "sane_control_option: get option %d (%s), value=%s\n",
|
||||||
|
option, device->opt[option].name, *(SANE_Bool *) value? "TRUE": "FALSE");
|
||||||
|
break;
|
||||||
|
|
||||||
case OPT_SENSOR_EMAIL:
|
case OPT_SENSOR_EMAIL:
|
||||||
case OPT_SENSOR_OCR:
|
case OPT_SENSOR_OCR:
|
||||||
case OPT_SENSOR_FILE:
|
case OPT_SENSOR_FILE:
|
||||||
|
@ -1151,14 +1180,28 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params)
|
||||||
|
|
||||||
DBG (DBG_EVENT, "sane_get_parameters\n");
|
DBG (DBG_EVENT, "sane_get_parameters\n");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Determine the resolutions to use.
|
||||||
|
* If --preview is selected, then just pick the lowest configured res.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
SANE_Word x_res = device->val[OPT_X_RESOLUTION].w;
|
||||||
|
SANE_Word y_res = device->val[OPT_Y_RESOLUTION].w;
|
||||||
|
|
||||||
|
if (device->val[OPT_PREVIEW].b)
|
||||||
|
{
|
||||||
|
x_res = device->model->x_res_list[1];
|
||||||
|
y_res = device->model->y_res_list[1];
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute the geometry in terms of pixels at the selected resolution.
|
* Compute the geometry in terms of pixels at the selected resolution.
|
||||||
* This is how the scanner wants it.
|
* This is how the scanner wants it.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SANE_Int pixel_x_width = SANE_UNFIX (device->val[OPT_BR_X].w -
|
SANE_Int pixel_x_width = SANE_UNFIX (device->val[OPT_BR_X].w -
|
||||||
device->val[OPT_TL_X].w) / MM_IN_INCH *
|
device->val[OPT_TL_X].w) / MM_IN_INCH *
|
||||||
device->val[OPT_X_RESOLUTION].w;
|
x_res;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* X coords must be a multiple of 8.
|
* X coords must be a multiple of 8.
|
||||||
|
@ -1170,13 +1213,13 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params)
|
||||||
|
|
||||||
SANE_Int pixel_y_height = SANE_UNFIX (device->val[OPT_BR_Y].w -
|
SANE_Int pixel_y_height = SANE_UNFIX (device->val[OPT_BR_Y].w -
|
||||||
device->val[OPT_TL_Y].w) / MM_IN_INCH *
|
device->val[OPT_TL_Y].w) / MM_IN_INCH *
|
||||||
device->val[OPT_Y_RESOLUTION].w;
|
y_res;
|
||||||
|
|
||||||
SANE_Int pixel_x_offset = SANE_UNFIX (device->val[OPT_TL_X].w) / MM_IN_INCH *
|
SANE_Int pixel_x_offset = SANE_UNFIX (device->val[OPT_TL_X].w) / MM_IN_INCH *
|
||||||
device->val[OPT_X_RESOLUTION].w;
|
x_res;
|
||||||
|
|
||||||
SANE_Int pixel_y_offset = SANE_UNFIX (device->val[OPT_TL_Y].w) / MM_IN_INCH *
|
SANE_Int pixel_y_offset = SANE_UNFIX (device->val[OPT_TL_Y].w) / MM_IN_INCH *
|
||||||
device->val[OPT_Y_RESOLUTION].w;
|
y_res;
|
||||||
|
|
||||||
params->lines = pixel_y_height;
|
params->lines = pixel_y_height;
|
||||||
params->last_frame = SANE_TRUE;
|
params->last_frame = SANE_TRUE;
|
||||||
|
@ -1194,7 +1237,7 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = device->driver->SetRes ((int)device->val[OPT_X_RESOLUTION].w, (int)device->val[OPT_Y_RESOLUTION].w);
|
rc = device->driver->SetRes ((SANE_Int)x_res, (SANE_Int)y_res);
|
||||||
if (rc != SANE_STATUS_GOOD)
|
if (rc != SANE_STATUS_GOOD)
|
||||||
{
|
{
|
||||||
return rc;
|
return rc;
|
||||||
|
|
Ładowanie…
Reference in New Issue