Commit 383bb720 authored by Alexandre Julliard's avatar Alexandre Julliard

sane.ds: Convert the SANE parameters to a private structure.

parent d63aa5dc
...@@ -372,8 +372,7 @@ static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 actio ...@@ -372,8 +372,7 @@ static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 actio
strcpy(mode, "Grayscale"); strcpy(mode, "Grayscale");
twCC = sane_option_set_str("mode", mode, &reload); twCC = sane_option_set_str("mode", mode, &reload);
} }
if (reload) if (reload) get_sane_params( &activeDS.frame_params );
sane_get_parameters (activeDS.deviceHandle, &activeDS.sane_param);
} }
break; break;
...@@ -394,7 +393,7 @@ static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 actio ...@@ -394,7 +393,7 @@ static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 actio
twCC = sane_option_set_str("mode", mode, &reload); twCC = sane_option_set_str("mode", mode, &reload);
} }
if (twCC != TWCC_SUCCESS) break; if (twCC != TWCC_SUCCESS) break;
if (reload) sane_get_parameters (activeDS.deviceHandle, &activeDS.sane_param); if (reload) get_sane_params( &activeDS.frame_params );
/* .. fall through intentional .. */ /* .. fall through intentional .. */
...@@ -458,7 +457,7 @@ static TW_UINT16 SANE_ICAPBitDepth(pTW_CAPABILITY pCapability, TW_UINT16 action) ...@@ -458,7 +457,7 @@ static TW_UINT16 SANE_ICAPBitDepth(pTW_CAPABILITY pCapability, TW_UINT16 action)
TRACE("ICAP_BITDEPTH\n"); TRACE("ICAP_BITDEPTH\n");
possible_values[0] = activeDS.sane_param.depth; possible_values[0] = activeDS.frame_params.depth;
switch (action) switch (action)
{ {
...@@ -469,15 +468,15 @@ static TW_UINT16 SANE_ICAPBitDepth(pTW_CAPABILITY pCapability, TW_UINT16 action) ...@@ -469,15 +468,15 @@ static TW_UINT16 SANE_ICAPBitDepth(pTW_CAPABILITY pCapability, TW_UINT16 action)
case MSG_GET: case MSG_GET:
twCC = msg_get_enum(pCapability, possible_values, ARRAY_SIZE(possible_values), twCC = msg_get_enum(pCapability, possible_values, ARRAY_SIZE(possible_values),
TWTY_UINT16, activeDS.sane_param.depth, activeDS.sane_param.depth); TWTY_UINT16, activeDS.frame_params.depth, activeDS.frame_params.depth);
break; break;
case MSG_GETDEFAULT: case MSG_GETDEFAULT:
/* .. Fall through intentional .. */ /* .. Fall through intentional .. */
case MSG_GETCURRENT: case MSG_GETCURRENT:
TRACE("Returning current bitdepth of %d\n", activeDS.sane_param.depth); TRACE("Returning current bitdepth of %d\n", activeDS.frame_params.depth);
twCC = set_onevalue(pCapability, TWTY_UINT16, activeDS.sane_param.depth); twCC = set_onevalue(pCapability, TWTY_UINT16, activeDS.frame_params.depth);
break; break;
} }
return twCC; return twCC;
...@@ -675,7 +674,7 @@ static TW_UINT16 SANE_ICAPPixelFlavor (pTW_CAPABILITY pCapability, TW_UINT16 act ...@@ -675,7 +674,7 @@ static TW_UINT16 SANE_ICAPPixelFlavor (pTW_CAPABILITY pCapability, TW_UINT16 act
TW_UINT16 twCC = TWCC_BADCAP; TW_UINT16 twCC = TWCC_BADCAP;
static const TW_UINT32 possible_values[] = { TWPF_CHOCOLATE, TWPF_VANILLA }; static const TW_UINT32 possible_values[] = { TWPF_CHOCOLATE, TWPF_VANILLA };
TW_UINT32 val; TW_UINT32 val;
TW_UINT32 flavor = activeDS.sane_param.depth == 1 ? TWPF_VANILLA : TWPF_CHOCOLATE; TW_UINT32 flavor = activeDS.frame_params.depth == 1 ? TWPF_VANILLA : TWPF_CHOCOLATE;
TRACE("ICAP_PIXELFLAVOR\n"); TRACE("ICAP_PIXELFLAVOR\n");
......
...@@ -309,11 +309,11 @@ TW_UINT16 SANE_SetupMemXferGet (pTW_IDENTITY pOrigin, ...@@ -309,11 +309,11 @@ TW_UINT16 SANE_SetupMemXferGet (pTW_IDENTITY pOrigin,
pTW_SETUPMEMXFER pSetupMemXfer = (pTW_SETUPMEMXFER)pData; pTW_SETUPMEMXFER pSetupMemXfer = (pTW_SETUPMEMXFER)pData;
TRACE("DG_CONTROL/DAT_SETUPMEMXFER/MSG_GET\n"); TRACE("DG_CONTROL/DAT_SETUPMEMXFER/MSG_GET\n");
if (activeDS.sane_param_valid) if (activeDS.frame_params.bytes_per_line)
{ {
pSetupMemXfer->MinBufSize = activeDS.sane_param.bytes_per_line; pSetupMemXfer->MinBufSize = activeDS.frame_params.bytes_per_line;
pSetupMemXfer->MaxBufSize = activeDS.sane_param.bytes_per_line * 8; pSetupMemXfer->MaxBufSize = activeDS.frame_params.bytes_per_line * 8;
pSetupMemXfer->Preferred = activeDS.sane_param.bytes_per_line * 2; pSetupMemXfer->Preferred = activeDS.frame_params.bytes_per_line * 2;
} }
else else
{ {
...@@ -392,8 +392,7 @@ TW_UINT16 SANE_EnableDSUserInterface (pTW_IDENTITY pOrigin, ...@@ -392,8 +392,7 @@ TW_UINT16 SANE_EnableDSUserInterface (pTW_IDENTITY pOrigin,
} }
else else
{ {
sane_get_parameters (activeDS.deviceHandle, &activeDS.sane_param); get_sane_params( &activeDS.frame_params );
activeDS.sane_param_valid = TRUE;
} }
} }
else else
......
...@@ -260,3 +260,30 @@ TW_FIX32 convert_sane_res_to_twain(int res) ...@@ -260,3 +260,30 @@ TW_FIX32 convert_sane_res_to_twain(int res)
value.Frac = res & 0xffff; value.Frac = res & 0xffff;
return value; return value;
} }
TW_UINT16 get_sane_params( struct frame_parameters *params )
{
SANE_Parameters sane_params;
TW_UINT16 rc = sane_status_to_twcc( sane_get_parameters( activeDS.deviceHandle, &sane_params ));
if (rc != TWCC_SUCCESS) return rc;
switch (sane_params.format)
{
case SANE_FRAME_GRAY:
params->format = FMT_GRAY;
break;
case SANE_FRAME_RGB:
params->format = FMT_RGB;
break;
default:
ERR("Unhandled source frame format %i\n", sane_params.format);
params->format = FMT_OTHER;
break;
}
params->last_frame = sane_params.last_frame;
params->bytes_per_line = sane_params.bytes_per_line;
params->pixels_per_line = sane_params.pixels_per_line;
params->lines = sane_params.lines;
params->depth = sane_params.depth;
return TWCC_SUCCESS;
}
...@@ -37,6 +37,16 @@ extern HINSTANCE SANE_instance DECLSPEC_HIDDEN; ...@@ -37,6 +37,16 @@ extern HINSTANCE SANE_instance DECLSPEC_HIDDEN;
#define TWCC_CHECKSTATUS (TWCC_CUSTOMBASE + 1) #define TWCC_CHECKSTATUS (TWCC_CUSTOMBASE + 1)
struct frame_parameters
{
enum { FMT_GRAY, FMT_RGB, FMT_OTHER } format;
BOOL last_frame;
int bytes_per_line;
int pixels_per_line;
int lines;
int depth;
};
/* internal information about an active data source */ /* internal information about an active data source */
struct tagActiveDS struct tagActiveDS
{ {
...@@ -49,9 +59,7 @@ struct tagActiveDS ...@@ -49,9 +59,7 @@ struct tagActiveDS
HWND progressWnd; /* window handle of the scanning window */ HWND progressWnd; /* window handle of the scanning window */
SANE_Handle deviceHandle; /* device handle */ SANE_Handle deviceHandle; /* device handle */
SANE_Parameters sane_param; /* parameters about the image struct frame_parameters frame_params; /* parameters about the image transferred */
transferred */
BOOL sane_param_valid; /* true if valid sane_param*/
BOOL sane_started; /* If sane_start has been called */ BOOL sane_started; /* If sane_start has been called */
INT deviceIndex; /* index of the current device */ INT deviceIndex; /* index of the current device */
...@@ -220,5 +228,6 @@ TW_UINT16 sane_option_get_scan_area( int *tlx, int *tly, int *brx, int *bry ) DE ...@@ -220,5 +228,6 @@ TW_UINT16 sane_option_get_scan_area( int *tlx, int *tly, int *brx, int *bry ) DE
TW_UINT16 sane_option_get_max_scan_area( int *tlx, int *tly, int *brx, int *bry ) DECLSPEC_HIDDEN; TW_UINT16 sane_option_get_max_scan_area( int *tlx, int *tly, int *brx, int *bry ) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_set_scan_area( int tlx, int tly, int brx, int bry, BOOL *reload ) DECLSPEC_HIDDEN; TW_UINT16 sane_option_set_scan_area( int tlx, int tly, int brx, int bry, BOOL *reload ) DECLSPEC_HIDDEN;
TW_FIX32 convert_sane_res_to_twain( int res ) DECLSPEC_HIDDEN; TW_FIX32 convert_sane_res_to_twain( int res ) DECLSPEC_HIDDEN;
TW_UINT16 get_sane_params( struct frame_parameters *params ) DECLSPEC_HIDDEN;
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment