Further cleanup of mustek_usb2.c.

merge-requests/1/head
Jan Hauffa 2011-04-10 18:42:05 +02:00 zatwierdzone przez m. allan noah
rodzic 39141a4c02
commit ccce2d4a9a
7 zmienionych plików z 527 dodań i 1190 usunięć

Plik diff jest za duży Load Diff

Wyświetl plik

@ -49,16 +49,6 @@
#ifndef MUSTEK_USB2_H
#define MUSTEK_USB2_H
#ifndef SANE_I18N
#define SANE_I18N(text) text
#endif
#define ENABLE(OPTION) s->opt[OPTION].cap &= ~SANE_CAP_INACTIVE
#define DISABLE(OPTION) s->opt[OPTION].cap |= SANE_CAP_INACTIVE
#define _MAX(a,b) ((a)>(b)?(a):(b))
#define _MIN(a,b) ((a)<(b)?(a):(b))
#define SCAN_BUFFER_SIZE (64 * 1024)
#define MAX_RESOLUTIONS 12
#define DEF_LINEARTTHRESHOLD 128
@ -100,34 +90,31 @@ typedef struct
/** @name Scanner model parameters */
/*@{ */
SANE_Word dpi_values[MAX_RESOLUTIONS]; /* possible resolutions */
SANE_Fixed x_size; /* size of scan area in mm */
SANE_Fixed y_size;
SANE_Fixed x_size_ta; /* size of scan area in TA mode in mm */
SANE_Fixed y_size_ta;
SANE_Int dpi_values[MAX_RESOLUTIONS]; /* possible resolutions */
SANE_Fixed x_size; /* Size of scan area in mm */
SANE_Fixed y_size; /* Size of scan area in mm */
SANE_Fixed x_size_ta; /* Size of scan area in TA mode in mm */
SANE_Fixed y_size_ta; /* Size of scan area in TA mode in mm */
RGBORDER line_mode_color_order; /* Order of the CCD/CIS colors */
RGBORDER line_mode_color_order; /* order of the CCD/CIS colors */
/*@} */
} Scanner_Model;
typedef struct Mustek_Scanner
{
/* all the state needed to define a scan request: */
struct Mustek_Scanner *next;
SANE_Option_Descriptor opt[NUM_OPTIONS];
Option_Value val[NUM_OPTIONS];
SANE_Parameters params; /**< SANE Parameters */
SANE_Parameters params;
Scanner_Model model;
SETPARAMETERS setpara;
GETPARAMETERS getpara;
TARGETIMAGE setpara;
SANE_Bool bIsScanning;
SANE_Bool bIsReading;
SANE_Word read_rows; /* transfer image's lines */
SANE_Byte *Scan_data_buf; /*store Scanned data for transfer */
SANE_Byte *Scan_data_buf_start; /*point to data need to transfer */
size_t scan_buffer_len; /* length of data buf */
SANE_Word read_rows; /* number of transfered image lines */
SANE_Byte *Scan_data_buf;
SANE_Byte *Scan_data_buf_start;
size_t scan_buffer_len;
} Mustek_Scanner;
#endif

Wyświetl plik

@ -45,11 +45,15 @@
This file implements a SANE backend for the Mustek BearPaw 2448 TA Pro
and similar USB2 scanners. */
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <unistd.h>
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#include "../include/sane/sane.h"
#include "../include/sane/sanei_usb.h"
@ -1979,7 +1983,7 @@ Asic_Close (PAsic chip)
if (chip->firmwarestate > FS_OPENED)
{
DBG (DBG_ASIC,
"Asic_Close: Scanner is scanning, try to stop scanning\n");
"Asic_Close: Scanner is scanning, trying to stop scanning\n");
Asic_ScanStop (chip);
}
@ -2592,8 +2596,7 @@ static SANE_Status
Asic_CheckFunctionKey (PAsic chip, SANE_Byte * key)
{
SANE_Status status;
SANE_Byte bBuffer_1 = 0xff;
SANE_Byte bBuffer_2 = 0xff;
SANE_Byte bBuffer_1, bBuffer_2;
DBG (DBG_ASIC, "Asic_CheckFunctionKey: Enter\n");
@ -2615,16 +2618,19 @@ Asic_CheckFunctionKey (PAsic chip, SANE_Byte * key)
if (status != SANE_STATUS_GOOD)
return status;
if ((~bBuffer_1 & 0x10) == 0x10)
*key = 0x01;
else if ((~bBuffer_1 & 0x01) == 0x01)
*key = 0x02;
else if ((~bBuffer_1 & 0x04) == 0x04)
*key = 0x04;
else if ((~bBuffer_2 & 0x08) == 0x08)
*key = 0x08;
else if ((~bBuffer_1 & 0x02) == 0x02)
*key = 0x10;
bBuffer_1 = ~bBuffer1;
bBuffer_2 = ~bBuffer2;
if (bBuffer_1 & 0x10)
*key = 1; /* Scan key pressed */
else if (bBuffer_1 & 0x01)
*key = 2; /* Copy key pressed */
else if (bBuffer_1 & 0x04)
*key = 3; /* Fax key pressed */
else if (bBuffer_2 & 0x08)
*key = 4; /* Email key pressed */
else if (bBuffer_1 & 0x02)
*key = 5; /* Panel key pressed */
else
*key = 0;
@ -2657,7 +2663,7 @@ Asic_IsTAConnected (PAsic chip, SANE_Bool * hasTA)
if (status != SANE_STATUS_GOOD)
return status;
*hasTA = ((~bBuffer_1 & 0x08) == 0x08) ? SANE_TRUE : SANE_FALSE;
*hasTA = (~bBuffer_1 & 0x08) ? SANE_TRUE : SANE_FALSE;
DBG (DBG_ASIC, "hasTA=%d\n", *hasTA);
DBG (DBG_ASIC, "Asic_IsTAConnected(): Exit\n");

Wyświetl plik

@ -45,8 +45,9 @@
This file implements a SANE backend for the Mustek BearPaw 2448 TA Pro
and similar USB2 scanners. */
#include <pthread.h> /* HOLD */
#include <stdlib.h>
#include <string.h>
#include <pthread.h> /* HOLD */
#include "mustek_usb2_asic.c"
@ -63,7 +64,6 @@ static SANE_Bool g_isScanning;
static SANE_Byte g_bScanBits;
static SANE_Byte *g_lpReadImageHead;
static const unsigned short s_wOpticalDpi[] = { 1200, 600, 300, 150, 75, 0 };
static unsigned short g_X;
static unsigned short g_Y;
static unsigned short g_Width;
@ -93,11 +93,8 @@ static unsigned short *g_pGammaTable;
static pthread_t g_threadid_readimage;
static COLORMODE g_ScanMode;
static TARGETIMAGE g_tiTarget;
static SCANTYPE g_ScanType = ST_Reflective;
static SCANSOURCE g_ssScanSource;
static SUGGESTSETTING g_ssSuggest;
static Asic g_chip;
static int g_nSecLength, g_nDarkSecLength;
@ -186,20 +183,20 @@ MustScanner_PowerControl (SANE_Bool isLampOn, SANE_Bool isTALampOn)
{
DBG (DBG_FUNC,
"MustScanner_PowerControl: Asic_TurnLamp return error\n");
return SANE_FALSE;
goto error;
}
if (SANE_STATUS_GOOD != Asic_IsTAConnected (&g_chip, &hasTA))
{
DBG (DBG_FUNC,
"MustScanner_PowerControl: Asic_IsTAConnected return error\n");
return SANE_FALSE;
goto error;
}
if (hasTA && (SANE_STATUS_GOOD != Asic_TurnTA (&g_chip, isTALampOn)))
{
DBG (DBG_FUNC, "MustScanner_PowerControl: Asic_TurnTA return error\n");
return SANE_FALSE;
goto error;
}
Asic_Close (&g_chip);
@ -207,6 +204,10 @@ MustScanner_PowerControl (SANE_Bool isLampOn, SANE_Bool isTALampOn)
DBG (DBG_FUNC,
"MustScanner_PowerControl: leave MustScanner_PowerControl\n");
return SANE_TRUE;
error:
Asic_Close (&g_chip);
return SANE_FALSE;
}
static SANE_Bool
@ -224,6 +225,7 @@ MustScanner_BackHome (void)
{
DBG (DBG_FUNC,
"MustScanner_BackHome: Asic_CarriageHome return error\n");
Asic_Close (&g_chip);
return SANE_FALSE;
}
@ -374,7 +376,7 @@ GetRgb48BitLineFull (SANE_Byte * lpLine, SANE_Bool isOrderInvert)
unsigned int dwRTempData, dwGTempData, dwBTempData;
unsigned short i = 0;
if (ST_Reflective == g_ScanType)
if (SS_Reflective == g_ssScanSource)
{
wRLinePosOdd = g_wtheReadyLines - g_wPixelDistance;
wGLinePosOdd = g_wtheReadyLines - g_wLineDistance - g_wPixelDistance;
@ -514,7 +516,7 @@ GetRgb24BitLineFull (SANE_Byte * lpLine, SANE_Bool isOrderInvert)
unsigned short tempR, tempG, tempB;
unsigned short i = 0;
if (ST_Reflective == g_ScanType)
if (SS_Reflective == g_ssScanSource)
{
wRLinePosOdd = g_wtheReadyLines - g_wPixelDistance;
wGLinePosOdd = g_wtheReadyLines - g_wLineDistance - g_wPixelDistance;
@ -612,7 +614,7 @@ GetMono16BitLineFull (SANE_Byte * lpLine,
unsigned short wLinePosEven;
unsigned short i = 0;
if (ST_Reflective == g_ScanType)
if (SS_Reflective == g_ssScanSource)
{
wLinePosOdd = g_wtheReadyLines - g_wPixelDistance;
wLinePosEven = g_wtheReadyLines;
@ -684,7 +686,7 @@ GetMono8BitLineFull (SANE_Byte * lpLine,
unsigned short wGray;
unsigned short i = 0;
if (ST_Reflective == g_ScanType)
if (SS_Reflective == g_ssScanSource)
{
wLinePosOdd = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines;
wLinePosEven = (g_wtheReadyLines) % g_wMaxScanLines;
@ -742,7 +744,7 @@ GetMono1BitLineFull (SANE_Byte * lpLine,
unsigned short wLinePosEven;
unsigned short i = 0;
if (ST_Reflective == g_ScanType)
if (SS_Reflective == g_ssScanSource)
{
wLinePosOdd = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines;
wLinePosEven = (g_wtheReadyLines) % g_wMaxScanLines;
@ -866,6 +868,10 @@ static SANE_Bool
MustScanner_GetRows (SANE_Byte * lpBlock, unsigned short * Rows,
SANE_Bool isOrderInvert)
{
unsigned int dwLineIncrement = g_SWBytesPerRow;
SANE_Bool fixEvenOdd = SANE_FALSE;
void (*pFunc)(SANE_Byte *, SANE_Bool) = NULL;
DBG (DBG_FUNC, "MustScanner_GetRows: call in\n");
if (!g_bOpened || !g_bPrepared)
@ -878,58 +884,55 @@ MustScanner_GetRows (SANE_Byte * lpBlock, unsigned short * Rows,
{
case CM_RGB48:
if (g_XDpi == SENSOR_DPI)
return MustScanner_GetLine (lpBlock, Rows, g_SWBytesPerRow,
GetRgb48BitLineFull, isOrderInvert,
SANE_FALSE);
pFunc = GetRgb48BitLineFull;
else
return MustScanner_GetLine (lpBlock, Rows, g_SWBytesPerRow,
GetRgb48BitLineHalf, isOrderInvert,
SANE_FALSE);
pFunc = GetRgb48BitLineHalf;
break;
case CM_RGB24:
if (g_XDpi == SENSOR_DPI)
return MustScanner_GetLine (lpBlock, Rows, g_SWBytesPerRow,
GetRgb24BitLineFull, isOrderInvert,
SANE_FALSE);
pFunc = GetRgb24BitLineFull;
else
return MustScanner_GetLine (lpBlock, Rows, g_SWBytesPerRow,
GetRgb24BitLineHalf, isOrderInvert,
SANE_FALSE);
pFunc = GetRgb24BitLineHalf;
break;
case CM_GRAY16:
if (g_XDpi == SENSOR_DPI)
return MustScanner_GetLine (lpBlock, Rows, g_SWBytesPerRow,
GetMono16BitLineFull, isOrderInvert,
SANE_TRUE);
{
fixEvenOdd = SANE_TRUE;
pFunc = GetMono16BitLineFull;
}
else
return MustScanner_GetLine (lpBlock, Rows, g_SWBytesPerRow,
GetMono16BitLineHalf, isOrderInvert,
SANE_FALSE);
{
pFunc = GetMono16BitLineHalf;
}
break;
case CM_GRAY8:
if (g_XDpi == SENSOR_DPI)
return MustScanner_GetLine (lpBlock, Rows, g_SWBytesPerRow,
GetMono8BitLineFull, isOrderInvert,
SANE_TRUE);
{
fixEvenOdd = SANE_TRUE;
pFunc = GetMono8BitLineFull;
}
else
return MustScanner_GetLine (lpBlock, Rows, g_SWBytesPerRow,
GetMono8BitLineHalf, isOrderInvert,
SANE_FALSE);
{
pFunc = GetMono8BitLineHalf;
}
break;
case CM_TEXT:
memset (lpBlock, 0, *Rows * g_SWWidth / 8);
dwLineIncrement /= 8;
if (g_XDpi == SENSOR_DPI)
return MustScanner_GetLine (lpBlock, Rows, g_SWBytesPerRow / 8,
GetMono1BitLineFull, isOrderInvert,
SANE_FALSE);
pFunc = GetMono1BitLineFull;
else
return MustScanner_GetLine (lpBlock, Rows, g_SWBytesPerRow / 8,
GetMono1BitLineHalf, isOrderInvert,
SANE_FALSE);
pFunc = GetMono1BitLineHalf;
break;
}
DBG (DBG_FUNC, "MustScanner_GetRows: leave MustScanner_GetRows\n");
return SANE_FALSE;
return MustScanner_GetLine (lpBlock, Rows, dwLineIncrement, pFunc,
isOrderInvert, fixEvenOdd);
}
static void
@ -1201,112 +1204,53 @@ QBET4 (SANE_Byte A, SANE_Byte B)
}
static SANE_Bool
MustScanner_ScanSuggest (PTARGETIMAGE pTarget, PSUGGESTSETTING pSuggest)
MustScanner_ScanSuggest (PTARGETIMAGE pTarget)
{
int i;
unsigned short wMaxWidth, wMaxHeight;
DBG (DBG_FUNC, "MustScanner_ScanSuggest: call in\n");
if (!pTarget || !pSuggest)
if (!pTarget)
{
DBG (DBG_FUNC, "MustScanner_ScanSuggest: parameters error\n");
return SANE_FALSE;
}
/* Look up optical X and Y resolution. */
for (i = 0; s_wOpticalDpi[i] != 0; i++)
{
if (s_wOpticalDpi[i] <= pTarget->wDpi)
{
pSuggest->wXDpi = s_wOpticalDpi[i];
break;
}
}
if (s_wOpticalDpi[i] == 0)
pSuggest->wXDpi = s_wOpticalDpi[--i];
pSuggest->wYDpi = pSuggest->wXDpi;
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pTarget->wDpi = %d\n",
pTarget->wDpi);
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pSuggest->w(X|Y)Dpi = %d\n",
pSuggest->wXDpi);
/* suggest scan area */
pSuggest->wX = (unsigned short) (((unsigned int) pTarget->wX *
pSuggest->wXDpi) / pTarget->wDpi);
pSuggest->wY = (unsigned short) (((unsigned int) pTarget->wY *
pSuggest->wYDpi) / pTarget->wDpi);
pSuggest->wWidth = (unsigned short) (((unsigned int) pTarget->wWidth *
pSuggest->wXDpi) / pTarget->wDpi);
pSuggest->wHeight = (unsigned short) (((unsigned int) pTarget->wHeight *
pSuggest->wYDpi) / pTarget->wDpi);
pSuggest->wWidth &= ~1;
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pTarget->wX = %d\n", pTarget->wX);
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pTarget->wY = %d\n", pTarget->wY);
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pTarget->wWidth = %d\n",
pTarget->wWidth);
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pTarget->wHeight = %d\n",
pTarget->wHeight);
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pSuggest->wX = %d\n", pSuggest->wX);
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pSuggest->wY = %d\n", pSuggest->wY);
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pSuggest->wWidth = %d\n",
pSuggest->wWidth);
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pSuggest->wHeight = %d\n",
pSuggest->wHeight);
if (pTarget->cmColorMode == CM_TEXT)
{
pSuggest->wWidth = (pSuggest->wWidth + 7) & ~7;
if (pSuggest->wWidth < 8)
pSuggest->wWidth = 8;
}
/* check width and height */
wMaxWidth = (MAX_SCANNING_WIDTH * pSuggest->wXDpi) / 300;
wMaxHeight = (MAX_SCANNING_HEIGHT * pSuggest->wYDpi) / 300;
wMaxWidth = (MAX_SCANNING_WIDTH * pTarget->wDpi) / 300;
wMaxHeight = (MAX_SCANNING_HEIGHT * pTarget->wDpi) / 300;
DBG (DBG_FUNC, "MustScanner_ScanSuggest: wMaxWidth = %d\n", wMaxWidth);
DBG (DBG_FUNC, "MustScanner_ScanSuggest: wMaxHeight = %d\n", wMaxHeight);
if (CM_TEXT == pTarget->cmColorMode)
wMaxWidth &= ~7;
if (pSuggest->wWidth > wMaxWidth)
pSuggest->wWidth = wMaxWidth;
if (pSuggest->wHeight > wMaxHeight)
pSuggest->wHeight = wMaxHeight;
g_Width = (pSuggest->wWidth + 15) & ~15; /* real scan width */
g_Height = pSuggest->wHeight;
pTarget->wWidth = _MIN (pTarget->wWidth, wMaxWidth);
pTarget->wHeight = _MIN (pTarget->wHeight, wMaxHeight);
g_Width = (pTarget->wWidth + 15) & ~15; /* real scan width */
g_Height = pTarget->wHeight;
DBG (DBG_FUNC, "MustScanner_ScanSuggest: g_Width=%d\n", g_Width);
switch (pTarget->cmColorMode)
{
case CM_RGB48:
pSuggest->dwBytesPerRow = (unsigned int) pSuggest->wWidth * 6;
pTarget->dwBytesPerRow = (unsigned int) pTarget->wWidth * 6;
break;
case CM_RGB24:
pSuggest->dwBytesPerRow = (unsigned int) pSuggest->wWidth * 3;
pTarget->dwBytesPerRow = (unsigned int) pTarget->wWidth * 3;
break;
case CM_GRAY16:
pSuggest->dwBytesPerRow = (unsigned int) pSuggest->wWidth * 2;
pTarget->dwBytesPerRow = (unsigned int) pTarget->wWidth * 2;
break;
case CM_GRAY8:
pSuggest->dwBytesPerRow = (unsigned int) pSuggest->wWidth;
pTarget->dwBytesPerRow = (unsigned int) pTarget->wWidth;
break;
case CM_TEXT:
pSuggest->dwBytesPerRow = (unsigned int) pSuggest->wWidth / 8;
pTarget->dwBytesPerRow = (unsigned int) pTarget->wWidth / 8;
break;
}
pSuggest->cmScanMode = pTarget->cmColorMode;
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pTarget->dwBytesPerRow = %d\n",
pTarget->dwBytesPerRow);
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pSuggest->dwBytesPerRow = %d\n",
pSuggest->dwBytesPerRow);
DBG (DBG_FUNC, "MustScanner_ScanSuggest: leave MustScanner_ScanSuggest\n");
return SANE_TRUE;
}

Wyświetl plik

@ -48,18 +48,18 @@
#ifndef MUSTEK_USB2_HIGH_H
#define MUSTEK_USB2_HIGH_H
typedef SANE_Byte SCANSOURCE;
#define SS_Reflective 0x00
#define SS_Positive 0x01
#define SS_Negative 0x02
typedef enum
{
SS_Reflective,
SS_Positive,
SS_Negative
} SCANSOURCE;
typedef SANE_Byte RGBORDER;
#define RO_RGB 0x00
#define RO_BGR 0x01
typedef SANE_Byte SCANTYPE;
#define ST_Reflective 0x00
#define ST_Transparent 0x01
typedef enum
{
RO_RGB,
RO_BGR
} RGBORDER;
typedef enum
{
@ -71,29 +71,6 @@ typedef enum
} COLORMODE;
typedef struct
{
unsigned int dwLineByteWidth;
unsigned int dwLength;
} GETPARAMETERS, *LPGETPARAMETERS;
typedef struct
{
unsigned short x1;
unsigned short y1;
unsigned short x2;
unsigned short y2;
} FRAME, *LPFRAME;
typedef struct
{
FRAME fmArea;
unsigned short wTargetDPI;
COLORMODE cmColorMode;
unsigned short wLinearThreshold; /* threshold for line art mode */
SCANSOURCE ssScanSource;
} SETPARAMETERS, *LPSETPARAMETERS;
typedef struct
{
RGBORDER roRgbOrder;
@ -105,26 +82,19 @@ typedef struct
typedef struct
{
COLORMODE cmColorMode;
SCANSOURCE ssScanSource;
unsigned short wDpi;
unsigned short wX;
unsigned short wY;
unsigned short wWidth;
unsigned short wHeight;
SCANSOURCE ssScanSource;
unsigned short wLineartThreshold;
unsigned int dwBytesPerRow;
} TARGETIMAGE, *PTARGETIMAGE;
typedef struct
{
COLORMODE cmScanMode;
unsigned short wXDpi;
unsigned short wYDpi;
unsigned short wX;
unsigned short wY;
unsigned short wWidth;
unsigned short wHeight;
unsigned int dwBytesPerRow;
} SUGGESTSETTING, *PSUGGESTSETTING;
#define _MAX(a,b) ((a)>(b)?(a):(b))
#define _MIN(a,b) ((a)<(b)?(a):(b))
#define R_GAIN 0
#define G_GAIN 0
@ -186,8 +156,7 @@ static void MustScanner_PrepareCalculateMaxMin (unsigned short wResolution);
static SANE_Bool MustScanner_CalculateMaxMin (SANE_Byte * pBuffer,
unsigned short * lpMaxValue,
unsigned short * lpMinValue);
static SANE_Bool MustScanner_ScanSuggest (PTARGETIMAGE pTarget,
PSUGGESTSETTING pSuggest);
static SANE_Bool MustScanner_ScanSuggest (PTARGETIMAGE pTarget);
static SANE_Bool MustScanner_StopScan (void);
static SANE_Bool MustScanner_PrepareScan (void);
static SANE_Bool MustScanner_GetRows (SANE_Byte * lpBlock,

Wyświetl plik

@ -47,11 +47,7 @@
static SANE_Bool Reflective_Reset (void);
static SANE_Bool Reflective_SetupScan (COLORMODE ColorMode,
unsigned short XDpi, unsigned short YDpi,
unsigned short X, unsigned short Y,
unsigned short Width,
unsigned short Height);
static SANE_Bool Reflective_SetupScan (TARGETIMAGE *pTarget);
static SANE_Bool Reflective_AdjustAD (void);
static SANE_Bool Reflective_FindTopLeft (unsigned short * lpwStartX,
unsigned short * lpwStartY);
@ -111,25 +107,8 @@ Reflective_Reset (void)
return SANE_TRUE;
}
/**********************************************************************
setup scanning process
Parameters:
ColorMode: ScanMode of Scanning, CM_RGB48, CM_GRAY and so on
XDpi: X Resolution
YDpi: Y Resolution
isInvert: the RGB order
X: X start coordinate
Y: Y start coordinate
Width: Width of Scan Image
Height: Height of Scan Image
Return value:
SANE_TRUE if the operation is success, SANE_FALSE otherwise
***********************************************************************/
static SANE_Bool
Reflective_SetupScan (COLORMODE ColorMode,
unsigned short XDpi, unsigned short YDpi,
unsigned short X, unsigned short Y,
unsigned short Width, unsigned short Height)
Reflective_SetupScan (TARGETIMAGE *pTarget)
{
DBG (DBG_FUNC, "Reflective_SetupScan: Call in\n");
@ -145,11 +124,11 @@ Reflective_SetupScan (COLORMODE ColorMode,
return SANE_FALSE;
}
g_ScanMode = ColorMode;
g_XDpi = XDpi;
g_YDpi = YDpi;
g_SWWidth = Width;
g_SWHeight = Height;
g_ScanMode = pTarget->cmColorMode;
g_XDpi = pTarget->wDpi;
g_YDpi = pTarget->wDpi;
g_SWWidth = pTarget->wWidth;
g_SWHeight = pTarget->wHeight;
switch (g_YDpi)
{
@ -276,7 +255,7 @@ Reflective_SetupScan (COLORMODE ColorMode,
if (1200 == g_XDpi)
{
g_X =
g_X * 1200 / FIND_LEFT_TOP_CALIBRATE_RESOLUTION + X * 1200 / g_XDpi +
g_X * 1200 / FIND_LEFT_TOP_CALIBRATE_RESOLUTION + pTarget->wX * 1200 / g_XDpi +
47;
}
@ -284,16 +263,16 @@ Reflective_SetupScan (COLORMODE ColorMode,
{
if (75 == g_XDpi)
{
g_X = g_X + X * 600 / g_XDpi;
g_X = g_X + pTarget->wX * 600 / g_XDpi;
}
else
{
g_X = g_X + X * 600 / g_XDpi + 23;
g_X = g_X + pTarget->wX * 600 / g_XDpi + 23;
}
}
g_Y =
g_Y * 1200 / FIND_LEFT_TOP_CALIBRATE_RESOLUTION + Y * 1200 / g_YDpi + 47;
g_Y * 1200 / FIND_LEFT_TOP_CALIBRATE_RESOLUTION + pTarget->wY * 1200 / g_YDpi + 47;
DBG (DBG_FUNC, "before line calibration,g_X=%d,g_Y=%d\n", g_X, g_Y);

Wyświetl plik

@ -47,12 +47,7 @@
static SANE_Bool Transparent_Reset (void);
static SANE_Bool Transparent_SetupScan (COLORMODE ColorMode,
unsigned short XDpi,
unsigned short YDpi,
unsigned short X, unsigned short Y,
unsigned short Width,
unsigned short Height);
static SANE_Bool Transparent_SetupScan (TARGETIMAGE *pTarget);
static SANE_Bool Transparent_AdjustAD (void);
static SANE_Bool Transparent_FindTopLeft (unsigned short * lpwStartX,
unsigned short * lpwStartY);
@ -113,25 +108,8 @@ Transparent_Reset (void)
return SANE_TRUE;
}
/**********************************************************************
setup scanning process
Parameters:
ColorMode: ScanMode of Scanning, CM_RGB48, CM_GRAY and so on
XDpi: X Resolution
YDpi: Y Resolution
isInvert: the RGB order
X: X start coordinate
Y: Y start coordinate
Width: Width of Scan Image
Height: Height of Scan Image
Return value:
SANE_TRUE if the operation is success, SANE_FALSE otherwise
***********************************************************************/
static SANE_Bool
Transparent_SetupScan (COLORMODE ColorMode,
unsigned short XDpi, unsigned short YDpi,
unsigned short X, unsigned short Y,
unsigned short Width, unsigned short Height)
Transparent_SetupScan (TARGETIMAGE *pTarget)
{
SANE_Bool hasTA;
unsigned short wTAShadingMinus = 0;
@ -150,11 +128,11 @@ Transparent_SetupScan (COLORMODE ColorMode,
return SANE_FALSE;
}
g_ScanMode = ColorMode;
g_XDpi = XDpi;
g_YDpi = YDpi;
g_SWWidth = Width;
g_SWHeight = Height;
g_ScanMode = pTarget->cmColorMode;
g_XDpi = pTarget->wDpi;
g_YDpi = pTarget->wDpi;
g_SWWidth = pTarget->wWidth;
g_SWHeight = pTarget->wHeight;
switch (g_YDpi)
{
@ -278,17 +256,17 @@ Transparent_SetupScan (COLORMODE ColorMode,
if (1200 == g_XDpi)
{
g_X =
g_X * 1200 / FIND_LEFT_TOP_CALIBRATE_RESOLUTION + X * 1200 / g_XDpi;
g_X * 1200 / FIND_LEFT_TOP_CALIBRATE_RESOLUTION + pTarget->wX * 1200 / g_XDpi;
}
else
{
if (75 == g_XDpi)
{
g_X = g_X + X * 600 / g_XDpi - 23;
g_X = g_X + pTarget->wX * 600 / g_XDpi - 23;
}
else
{
g_X = g_X + X * 600 / g_XDpi;
g_X = g_X + pTarget->wX * 600 / g_XDpi;
}
}
@ -306,7 +284,7 @@ Transparent_SetupScan (COLORMODE ColorMode,
"g_YDpi=%d, g_X=%d, g_Y=%d, g_Width=%d, g_Height=%d\n",
g_bScanBits, g_XDpi, g_YDpi, g_X, g_Y, g_Width, g_Height);
g_Y = Y * 1200 / g_YDpi + (300 - 40) + 189;
g_Y = pTarget->wY * 1200 / g_YDpi + (300 - 40) + 189;
Asic_MotorMove (&g_chip, SANE_TRUE, g_Y - 360);
g_Y = 360;