kopia lustrzana https://gitlab.com/sane-project/backends
Move some code that was duplicated in mustek_usb2_transparent.c and mustek_usb2_reflective.c to mustek_usb2_high.c.
rodzic
db37c13bb3
commit
972fc54793
|
@ -667,22 +667,11 @@ static SANE_Bool
|
|||
GetParameters (LPGETPARAMETERS pGetParameters)
|
||||
{
|
||||
DBG (DBG_FUNC, "GetParameters: start\n");
|
||||
if (ST_Reflective == g_ScanType)
|
||||
{
|
||||
if (FALSE == Reflective_ScanSuggest (&g_tiTarget, &g_ssSuggest))
|
||||
{
|
||||
DBG (DBG_ERR, "GetParameters: Reflective_ScanSuggest error\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FALSE == Transparent_ScanSuggest (&g_tiTarget, &g_ssSuggest))
|
||||
{
|
||||
DBG (DBG_ERR, "GetParameters: Transparent_ScanSuggest error\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (FALSE == MustScanner_ScanSuggest (&g_tiTarget, &g_ssSuggest))
|
||||
{
|
||||
DBG (DBG_ERR, "GetParameters: MustScanner_ScanSuggest error\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pGetParameters->dwLength = (unsigned int) g_ssSuggest.wHeight;
|
||||
pGetParameters->dwLineByteWidth = g_ssSuggest.dwBytesPerRow;
|
||||
|
@ -754,16 +743,8 @@ ReadScannedData (LPIMAGEROWS pImageRows)
|
|||
|
||||
DBG (DBG_INFO, "ReadScannedData: wanted Rows = %d\n", Rows);
|
||||
|
||||
if (ST_Reflective == g_ScanType)
|
||||
{
|
||||
if (FALSE == Reflective_GetRows (lpBlock, &Rows, isRGBInvert))
|
||||
return FALSE;
|
||||
}
|
||||
else if (SS_Positive == g_ssScanSource)
|
||||
{
|
||||
if (FALSE == Transparent_GetRows (lpBlock, &Rows, isRGBInvert))
|
||||
return FALSE;
|
||||
}
|
||||
if (FALSE == MustScanner_GetRows (lpBlock, &Rows, isRGBInvert))
|
||||
return FALSE;
|
||||
|
||||
pImageRows->wXferedLineNum = Rows;
|
||||
|
||||
|
@ -771,9 +752,7 @@ ReadScannedData (LPIMAGEROWS pImageRows)
|
|||
{
|
||||
int TotalSize = Rows * g_ssSuggest.dwBytesPerRow;
|
||||
for (i = 0; i < TotalSize; i++)
|
||||
{
|
||||
*(lpBlock++) ^= 0xff;
|
||||
}
|
||||
*(lpBlock++) ^= 0xff;
|
||||
}
|
||||
|
||||
if (SS_Negative == g_ssScanSource)
|
||||
|
@ -790,18 +769,14 @@ ReadScannedData (LPIMAGEROWS pImageRows)
|
|||
DBG (DBG_INFO,
|
||||
"ReadScannedData: malloc the negative data is success!\n");
|
||||
g_bIsMallocNegData = TRUE;
|
||||
if (!Transparent_GetRows
|
||||
if (!MustScanner_GetRows
|
||||
(g_lpNegImageData, &g_SWHeight, isRGBInvert))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
DBG (DBG_INFO, "ReadScannedData: get image data is over!\n");
|
||||
|
||||
for (i = 0; i < (int) TotalImgeSize; i++)
|
||||
{
|
||||
*(g_lpNegImageData++) ^= 0xff;
|
||||
}
|
||||
*(g_lpNegImageData++) ^= 0xff;
|
||||
g_lpNegImageData = lpTempData;
|
||||
AutoLevel (g_lpNegImageData, g_ScanMode, g_SWHeight,
|
||||
g_ssSuggest.dwBytesPerRow);
|
||||
|
@ -835,15 +810,11 @@ ReadScannedData (LPIMAGEROWS pImageRows)
|
|||
int TotalSize = Rows * g_ssSuggest.dwBytesPerRow;
|
||||
DBG (DBG_INFO,
|
||||
"ReadScannedData: malloc the negative data is fail!\n");
|
||||
if (!Transparent_GetRows (lpReturnData, &Rows, isRGBInvert))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!MustScanner_GetRows (lpReturnData, &Rows, isRGBInvert))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < TotalSize; i++)
|
||||
{
|
||||
*(lpReturnData++) ^= 0xff;
|
||||
}
|
||||
*(lpReturnData++) ^= 0xff;
|
||||
pImageRows->wXferedLineNum = Rows;
|
||||
|
||||
g_dwAlreadyGetNegLines += Rows;
|
||||
|
@ -875,17 +846,10 @@ StopScan (void)
|
|||
|
||||
DBG (DBG_FUNC, "StopScan: start\n");
|
||||
|
||||
/*stop read data and kill thread */
|
||||
if (ST_Reflective == g_ScanType)
|
||||
{
|
||||
rt = Reflective_StopScan ();
|
||||
}
|
||||
else
|
||||
{
|
||||
rt = Transparent_StopScan ();
|
||||
}
|
||||
/* stop reading data and kill thread */
|
||||
rt = MustScanner_StopScan ();
|
||||
|
||||
/*free gamma table */
|
||||
/* free gamma table */
|
||||
if (g_isSelfGamma && g_pGammaTable != NULL)
|
||||
{
|
||||
for (i = 0; i < 20; i++)
|
||||
|
@ -898,14 +862,13 @@ StopScan (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
sleep (1); /*waiting ReadScannedData return. */
|
||||
sleep (1); /* waiting for ReadScannedData to return */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*free image buffer */
|
||||
/* free image buffer */
|
||||
if (g_lpReadImageHead != NULL)
|
||||
|
||||
{
|
||||
free (g_lpReadImageHead);
|
||||
g_lpReadImageHead = NULL;
|
||||
|
|
|
@ -2594,3 +2594,310 @@ QBET4 (SANE_Byte A, SANE_Byte B)
|
|||
B = B & 0x0f;
|
||||
return bQBET[A][B];
|
||||
}
|
||||
|
||||
static SANE_Bool
|
||||
MustScanner_ScanSuggest (PTARGETIMAGE pTarget, PSUGGESTSETTING pSuggest)
|
||||
{
|
||||
int i;
|
||||
unsigned short wMaxWidth, wMaxHeight;
|
||||
|
||||
DBG (DBG_FUNC, "MustScanner_ScanSuggest: call in\n");
|
||||
|
||||
if (NULL == pTarget || NULL == pSuggest)
|
||||
{
|
||||
DBG (DBG_FUNC, "MustScanner_ScanSuggest: parameters error\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* 1. Look up optical Y resolution */
|
||||
for (i = 0; s_wOpticalDpi[i] != 0; i++)
|
||||
{
|
||||
if (s_wOpticalDpi[i] <= pTarget->wDpi)
|
||||
{
|
||||
pSuggest->wYDpi = s_wOpticalDpi[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (s_wOpticalDpi[i] == 0)
|
||||
{
|
||||
i--;
|
||||
pSuggest->wYDpi = s_wOpticalDpi[i];
|
||||
}
|
||||
|
||||
/* 2. Look up optical X 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)
|
||||
{
|
||||
i--;
|
||||
pSuggest->wXDpi = s_wOpticalDpi[i];
|
||||
}
|
||||
|
||||
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pTarget->wDpi = %d\n",
|
||||
pTarget->wDpi);
|
||||
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pSuggest->wXDpi = %d\n",
|
||||
pSuggest->wXDpi);
|
||||
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pSuggest->wYDpi = %d\n",
|
||||
pSuggest->wYDpi);
|
||||
|
||||
/* 3. suggest scan area */
|
||||
pSuggest->wX = (unsigned short) (((unsigned int) (pTarget->wX) *
|
||||
(unsigned int) (pSuggest->wXDpi)) / (unsigned int) (pTarget->wDpi));
|
||||
pSuggest->wY = (unsigned short) (((unsigned int) (pTarget->wY) *
|
||||
(unsigned int) (pSuggest->wYDpi)) / (unsigned int) (pTarget->wDpi));
|
||||
pSuggest->wWidth = (unsigned short) (((unsigned int) (pTarget->wWidth) *
|
||||
(unsigned int) (pSuggest->wXDpi)) / (unsigned int) (pTarget->wDpi));
|
||||
pSuggest->wHeight = (unsigned short) (((unsigned int) (pTarget->wHeight) *
|
||||
(unsigned int) (pSuggest->wYDpi)) / (unsigned int) (pTarget->wDpi));
|
||||
|
||||
pSuggest->wWidth = (pSuggest->wWidth / 2) * 2;
|
||||
|
||||
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) >> 3) << 3;
|
||||
if (pSuggest->wWidth < 8)
|
||||
pSuggest->wWidth = 8;
|
||||
}
|
||||
|
||||
/* 4. check width and height */
|
||||
wMaxWidth = (MAX_SCANNING_WIDTH * pSuggest->wXDpi) / 300;
|
||||
wMaxHeight = (MAX_SCANNING_HEIGHT * pSuggest->wYDpi) / 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 = (wMaxWidth >> 3) << 3;
|
||||
|
||||
if (pSuggest->wWidth > wMaxWidth)
|
||||
pSuggest->wWidth = wMaxWidth;
|
||||
if (pSuggest->wHeight > wMaxHeight)
|
||||
pSuggest->wHeight = wMaxHeight;
|
||||
|
||||
DBG (DBG_FUNC, "MustScanner_ScanSuggest: g_Width=%d\n", g_Width);
|
||||
|
||||
g_Width = ((pSuggest->wWidth + 15) >> 4) << 4; /* real scan width */
|
||||
|
||||
DBG (DBG_FUNC, "MustScanner_ScanSuggest: again, g_Width=%d\n", g_Width);
|
||||
|
||||
g_Height = pSuggest->wHeight;
|
||||
|
||||
if (pTarget->isOptimalSpeed)
|
||||
{
|
||||
switch (pTarget->cmColorMode)
|
||||
{
|
||||
case CM_RGB48:
|
||||
pSuggest->cmScanMode = CM_RGB48;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 6);
|
||||
break;
|
||||
case CM_RGB24:
|
||||
pSuggest->cmScanMode = CM_RGB24ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 3);
|
||||
break;
|
||||
case CM_GRAY16:
|
||||
pSuggest->cmScanMode = CM_GRAY16ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 2);
|
||||
break;
|
||||
case CM_GRAY8:
|
||||
pSuggest->cmScanMode = CM_GRAY8ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth));
|
||||
break;
|
||||
case CM_TEXT:
|
||||
pSuggest->cmScanMode = CM_TEXT;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) (pSuggest->wWidth) / 8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (pTarget->cmColorMode)
|
||||
{
|
||||
case CM_RGB48:
|
||||
pSuggest->cmScanMode = CM_RGB48;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 6);
|
||||
break;
|
||||
case CM_RGB24:
|
||||
pSuggest->cmScanMode = CM_RGB24ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 3);
|
||||
break;
|
||||
case CM_GRAY16:
|
||||
pSuggest->cmScanMode = CM_GRAY16ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 2);
|
||||
break;
|
||||
case CM_GRAY8:
|
||||
pSuggest->cmScanMode = CM_GRAY8ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth));
|
||||
break;
|
||||
case CM_TEXT:
|
||||
pSuggest->cmScanMode = CM_TEXT;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) (pSuggest->wWidth) / 8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DBG (DBG_FUNC, "MustScanner_ScanSuggest: pSuggest->dwBytesPerRow = %d\n",
|
||||
pSuggest->dwBytesPerRow);
|
||||
DBG (DBG_FUNC, "MustScanner_ScanSuggest: leave MustScanner_ScanSuggest\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static SANE_Bool
|
||||
MustScanner_StopScan (void)
|
||||
{
|
||||
DBG (DBG_FUNC, "MustScanner_StopScan: call in\n");
|
||||
if (!g_bOpened)
|
||||
{
|
||||
DBG (DBG_FUNC, "MustScanner_StopScan: scanner not opened\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (!g_bPrepared)
|
||||
{
|
||||
DBG (DBG_FUNC, "MustScanner_StopScan: scanner not prepared\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_isCanceled = TRUE; /* tell parent process to stop reading image data */
|
||||
|
||||
pthread_cancel (g_threadid_readimage);
|
||||
pthread_join (g_threadid_readimage, NULL);
|
||||
|
||||
DBG (DBG_FUNC, "MustScanner_StopScan: thread exit\n");
|
||||
|
||||
Asic_ScanStop (&g_chip);
|
||||
Asic_Close (&g_chip);
|
||||
|
||||
g_bOpened = FALSE;
|
||||
|
||||
DBG (DBG_FUNC, "MustScanner_StopScan: leave MustScanner_StopScan\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static SANE_Bool
|
||||
MustScanner_PrepareScan (void)
|
||||
{
|
||||
DBG (DBG_FUNC, "MustScanner_PrepareScan: call in\n");
|
||||
|
||||
g_wScanLinesPerBlock = g_dwBufferSize / g_BytesPerRow;
|
||||
g_wMaxScanLines = g_dwImageBufferSize / g_BytesPerRow;
|
||||
g_wMaxScanLines =
|
||||
(g_wMaxScanLines / g_wScanLinesPerBlock) * g_wScanLinesPerBlock;
|
||||
|
||||
g_isCanceled = FALSE;
|
||||
|
||||
g_dwScannedTotalLines = 0;
|
||||
|
||||
switch (g_ScanMode)
|
||||
{
|
||||
case CM_RGB48:
|
||||
case CM_RGB24ext:
|
||||
g_wtheReadyLines = g_wLineDistance * 2 + g_wPixelDistance;
|
||||
break;
|
||||
|
||||
case CM_GRAY16ext:
|
||||
case CM_GRAY8ext:
|
||||
case CM_TEXT:
|
||||
g_wtheReadyLines = g_wPixelDistance;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_wtheReadyLines = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DBG (DBG_FUNC, "MustScanner_PrepareScan: g_wtheReadyLines=%d\n",
|
||||
g_wtheReadyLines);
|
||||
|
||||
DBG (DBG_FUNC, "MustScanner_PrepareScan: g_lpReadImageHead malloc %d bytes\n",
|
||||
g_dwImageBufferSize);
|
||||
g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize);
|
||||
if (g_lpReadImageHead == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC, "MustScanner_PrepareScan: g_lpReadImageHead malloc " \
|
||||
"error\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Asic_ScanStart (&g_chip);
|
||||
|
||||
DBG (DBG_FUNC, "MustScanner_PrepareScan: leave MustScanner_PrepareScan\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static SANE_Bool
|
||||
MustScanner_GetRows (SANE_Byte * lpBlock, unsigned short * Rows,
|
||||
SANE_Bool isOrderInvert)
|
||||
{
|
||||
DBG (DBG_FUNC, "MustScanner_GetRows: call in\n");
|
||||
if (!g_bOpened || !g_bPrepared)
|
||||
{
|
||||
DBG (DBG_FUNC, "MustScanner_GetRows: scanner not opened or prepared\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (g_ScanMode)
|
||||
{
|
||||
case CM_RGB48:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetRgb48BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetRgb48BitLine (lpBlock, isOrderInvert, Rows);
|
||||
|
||||
case CM_RGB24ext:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetRgb24BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetRgb24BitLine (lpBlock, isOrderInvert, Rows);
|
||||
|
||||
case CM_GRAY16ext:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetMono16BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetMono16BitLine (lpBlock, isOrderInvert, Rows);
|
||||
|
||||
case CM_GRAY8ext:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetMono8BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetMono8BitLine (lpBlock, isOrderInvert, Rows);
|
||||
|
||||
case CM_TEXT:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetMono1BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetMono1BitLine (lpBlock, isOrderInvert, Rows);
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DBG (DBG_FUNC, "MustScanner_GetRows: leave MustScanner_GetRows\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -214,6 +214,13 @@ static void MustScanner_CalculateMaxMin (SANE_Byte * pBuffer,
|
|||
unsigned short * lpMaxValue,
|
||||
unsigned short * lpMinValue,
|
||||
unsigned short wResolution);
|
||||
static SANE_Bool MustScanner_ScanSuggest (PTARGETIMAGE pTarget,
|
||||
PSUGGESTSETTING pSuggest);
|
||||
static SANE_Bool MustScanner_StopScan (void);
|
||||
static SANE_Bool MustScanner_PrepareScan (void);
|
||||
static SANE_Bool MustScanner_GetRows (SANE_Byte * lpBlock,
|
||||
unsigned short * Rows,
|
||||
SANE_Bool isOrderInvert);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,16 +46,13 @@
|
|||
and similar USB2 scanners. */
|
||||
|
||||
static SANE_Bool Reflective_Reset (void);
|
||||
static SANE_Bool Reflective_ScanSuggest (PTARGETIMAGE pTarget, PSUGGESTSETTING pSuggest);
|
||||
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_StopScan (void);
|
||||
static SANE_Bool Reflective_GetRows (SANE_Byte * lpBlock, unsigned short * Rows, SANE_Bool isOrderInvert);
|
||||
static SANE_Bool Reflective_AdjustAD (void);
|
||||
static SANE_Bool Reflective_FindTopLeft (unsigned short * lpwStartX, unsigned short * lpwStartY);
|
||||
static SANE_Bool Reflective_LineCalibration16Bits (void);
|
||||
static SANE_Bool Reflective_PrepareScan (void);
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
reset the scanner status
|
||||
|
@ -121,195 +118,6 @@ Reflective_Reset (void)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
get the suggest parameter of scaning
|
||||
Parameters:
|
||||
pTarget: the information of scaning
|
||||
pSuggest: suggest parameter of scaning
|
||||
Return value:
|
||||
TRUE if the operation is success, FALSE otherwise
|
||||
***********************************************************************/
|
||||
static SANE_Bool
|
||||
Reflective_ScanSuggest (PTARGETIMAGE pTarget, PSUGGESTSETTING pSuggest)
|
||||
{
|
||||
int i;
|
||||
unsigned short wMaxWidth, wMaxHeight;
|
||||
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: call in\n");
|
||||
|
||||
if (NULL == pTarget || NULL == pSuggest)
|
||||
{
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: parameters error\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*1. Looking up Optical Y Resolution */
|
||||
for (i = 0; s_wOpticalDpi[i] != 0; i++)
|
||||
{
|
||||
if (s_wOpticalDpi[i] <= pTarget->wDpi)
|
||||
{
|
||||
pSuggest->wYDpi = s_wOpticalDpi[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (s_wOpticalDpi[i] == 0)
|
||||
{
|
||||
i--;
|
||||
pSuggest->wYDpi = s_wOpticalDpi[i];
|
||||
}
|
||||
|
||||
/*2. Looking up Optical X 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)
|
||||
{
|
||||
i--;
|
||||
pSuggest->wXDpi = s_wOpticalDpi[i];
|
||||
}
|
||||
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: pTarget->wDpi = %d\n",
|
||||
pTarget->wDpi);
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->wXDpi = %d\n",
|
||||
pSuggest->wXDpi);
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->wYDpi = %d\n",
|
||||
pSuggest->wYDpi);
|
||||
|
||||
/*3. suggest scan area */
|
||||
pSuggest->wX =
|
||||
(unsigned short) (((unsigned int) (pTarget->wX) * (unsigned int) (pSuggest->wXDpi)) /
|
||||
(unsigned int) (pTarget->wDpi));
|
||||
pSuggest->wY =
|
||||
(unsigned short) (((unsigned int) (pTarget->wY) * (unsigned int) (pSuggest->wYDpi)) /
|
||||
(unsigned int) (pTarget->wDpi));
|
||||
pSuggest->wWidth =
|
||||
(unsigned short) (((unsigned int) (pTarget->wWidth) * (unsigned int) (pSuggest->wXDpi)) /
|
||||
(unsigned int) (pTarget->wDpi));
|
||||
pSuggest->wHeight =
|
||||
(unsigned short) (((unsigned int) (pTarget->wHeight) * (unsigned int) (pSuggest->wYDpi)) /
|
||||
(unsigned int) (pTarget->wDpi));
|
||||
|
||||
pSuggest->wWidth = (pSuggest->wWidth / 2) * 2;
|
||||
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: pTarget->wX = %d\n", pTarget->wX);
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: pTarget->wY = %d\n", pTarget->wY);
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: pTarget->wWidth = %d\n",
|
||||
pTarget->wWidth);
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: pTarget->wHeight = %d\n",
|
||||
pTarget->wHeight);
|
||||
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->wX = %d\n", pSuggest->wX);
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->wY = %d\n", pSuggest->wY);
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->wWidth = %d\n",
|
||||
pSuggest->wWidth);
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->wHeight = %d\n",
|
||||
pSuggest->wHeight);
|
||||
|
||||
if (pTarget->cmColorMode == CM_TEXT)
|
||||
{
|
||||
pSuggest->wWidth = ((pSuggest->wWidth + 7) >> 3) << 3;
|
||||
if (pSuggest->wWidth < 8)
|
||||
pSuggest->wWidth = 8;
|
||||
}
|
||||
|
||||
/*4. check width and height */
|
||||
wMaxWidth = (MAX_SCANNING_WIDTH * pSuggest->wXDpi) / 300;
|
||||
wMaxHeight = (3480 * pSuggest->wYDpi) / 300; /* 3480 for bumping */
|
||||
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: wMaxWidth = %d\n", wMaxWidth);
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: wMaxHeight = %d\n", wMaxHeight);
|
||||
|
||||
if (CM_TEXT == pTarget->cmColorMode)
|
||||
{
|
||||
wMaxWidth = (wMaxWidth >> 3) << 3;
|
||||
}
|
||||
if (pSuggest->wWidth > wMaxWidth)
|
||||
{
|
||||
pSuggest->wWidth = wMaxWidth;
|
||||
}
|
||||
|
||||
|
||||
if (pSuggest->wHeight > wMaxHeight)
|
||||
{
|
||||
pSuggest->wHeight = wMaxHeight;
|
||||
}
|
||||
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: g_Width=%d\n", g_Width);
|
||||
|
||||
g_Width = ((pSuggest->wWidth + 15) >> 4) << 4; /*Real Scan Width */
|
||||
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: again, g_Width=%d\n", g_Width);
|
||||
|
||||
g_Height = pSuggest->wHeight;
|
||||
|
||||
if (pTarget->isOptimalSpeed)
|
||||
{
|
||||
switch (pTarget->cmColorMode)
|
||||
{
|
||||
case CM_RGB48:
|
||||
pSuggest->cmScanMode = CM_RGB48;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 6);
|
||||
break;
|
||||
case CM_RGB24:
|
||||
pSuggest->cmScanMode = CM_RGB24ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 3);
|
||||
break;
|
||||
case CM_GRAY16:
|
||||
pSuggest->cmScanMode = CM_GRAY16ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 2);
|
||||
break;
|
||||
case CM_GRAY8:
|
||||
pSuggest->cmScanMode = CM_GRAY8ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth));
|
||||
break;
|
||||
case CM_TEXT:
|
||||
pSuggest->cmScanMode = CM_TEXT;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) (pSuggest->wWidth) / 8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (pTarget->cmColorMode)
|
||||
{
|
||||
case CM_RGB48:
|
||||
pSuggest->cmScanMode = CM_RGB48;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 6);
|
||||
break;
|
||||
case CM_RGB24:
|
||||
pSuggest->cmScanMode = CM_RGB24ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 3);
|
||||
break;
|
||||
case CM_GRAY16:
|
||||
pSuggest->cmScanMode = CM_GRAY16ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 2);
|
||||
break;
|
||||
case CM_GRAY8:
|
||||
pSuggest->cmScanMode = CM_GRAY8ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth));
|
||||
break;
|
||||
case CM_TEXT:
|
||||
pSuggest->cmScanMode = CM_TEXT;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) (pSuggest->wWidth) / 8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->dwBytesPerRow = %d\n",
|
||||
pSuggest->dwBytesPerRow);
|
||||
DBG (DBG_FUNC, "Reflective_ScanSuggest: leave Reflective_ScanSuggest\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
setup scanning process
|
||||
Parameters:
|
||||
|
@ -527,7 +335,7 @@ Reflective_SetupScan (COLORMODE ColorMode,
|
|||
g_Height);
|
||||
|
||||
DBG (DBG_FUNC, "Reflective_SetupScan: leave Reflective_SetupScan\n");
|
||||
return Reflective_PrepareScan ();
|
||||
return MustScanner_PrepareScan ();
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -1235,44 +1043,6 @@ Reflective_FindTopLeft (unsigned short * lpwStartX, unsigned short * lpwStartY)
|
|||
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Stop scan
|
||||
Return value:
|
||||
TRUE if operation is success, FALSE otherwise
|
||||
***********************************************************************/
|
||||
static SANE_Bool
|
||||
Reflective_StopScan (void)
|
||||
{
|
||||
DBG (DBG_FUNC, "Reflective_StopScan: call in\n");
|
||||
if (!g_bOpened)
|
||||
{
|
||||
DBG (DBG_FUNC, "Reflective_StopScan: scanner not opened\n");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
if (!g_bPrepared)
|
||||
{
|
||||
DBG (DBG_FUNC, "Reflective_StopScan: scanner not prepared\n");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_isCanceled = TRUE; /*tell parent process stop read image */
|
||||
|
||||
pthread_cancel (g_threadid_readimage);
|
||||
pthread_join (g_threadid_readimage, NULL);
|
||||
|
||||
DBG (DBG_FUNC, "Reflective_StopScan: thread exit\n");
|
||||
|
||||
Asic_ScanStop (&g_chip);
|
||||
Asic_Close (&g_chip);
|
||||
|
||||
g_bOpened = FALSE;
|
||||
|
||||
DBG (DBG_FUNC, "Reflective_StopScan: leave Reflective_StopScan\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Get the calibration data
|
||||
Return value:
|
||||
|
@ -1685,180 +1455,3 @@ Reflective_LineCalibration16Bits (void)
|
|||
"Reflective_LineCalibration16Bits: leave Reflective_LineCalibration16Bits\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Prepare scan image
|
||||
Return value:
|
||||
TRUE if operation is success, FALSE otherwise
|
||||
***********************************************************************/
|
||||
static SANE_Bool
|
||||
Reflective_PrepareScan (void)
|
||||
{
|
||||
g_wScanLinesPerBlock = g_dwBufferSize / g_BytesPerRow;
|
||||
g_wMaxScanLines = g_dwImageBufferSize / g_BytesPerRow;
|
||||
g_wMaxScanLines =
|
||||
(g_wMaxScanLines / g_wScanLinesPerBlock) * g_wScanLinesPerBlock;
|
||||
|
||||
g_isCanceled = FALSE;
|
||||
|
||||
g_dwScannedTotalLines = 0;
|
||||
g_wtheReadyLines = 0;
|
||||
|
||||
switch (g_ScanMode)
|
||||
{
|
||||
case CM_RGB48:
|
||||
g_wtheReadyLines = g_wLineDistance * 2 + g_wPixelDistance;
|
||||
DBG (DBG_FUNC, "Reflective_PrepareScan:g_wtheReadyLines=%d\n",
|
||||
g_wtheReadyLines);
|
||||
|
||||
DBG (DBG_FUNC,
|
||||
"Reflective_PrepareScan:g_lpReadImageHead malloc %d Bytes\n",
|
||||
g_dwImageBufferSize);
|
||||
g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize);
|
||||
if (g_lpReadImageHead == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC,
|
||||
"Reflective_PrepareScan: g_lpReadImageHead malloc error \n");
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case CM_RGB24ext:
|
||||
g_wtheReadyLines = g_wLineDistance * 2 + g_wPixelDistance;
|
||||
DBG (DBG_FUNC, "Reflective_PrepareScan:g_wtheReadyLines=%d\n",
|
||||
g_wtheReadyLines);
|
||||
|
||||
DBG (DBG_FUNC,
|
||||
"Reflective_PrepareScan:g_lpReadImageHead malloc %d Bytes\n",
|
||||
g_dwImageBufferSize);
|
||||
g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize);
|
||||
if (g_lpReadImageHead == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC,
|
||||
"Reflective_PrepareScan: g_lpReadImageHead malloc error \n");
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case CM_GRAY16ext:
|
||||
g_wtheReadyLines = g_wPixelDistance;
|
||||
DBG (DBG_FUNC, "Reflective_PrepareScan:g_wtheReadyLines=%d\n",
|
||||
g_wtheReadyLines);
|
||||
|
||||
DBG (DBG_FUNC,
|
||||
"Reflective_PrepareScan:g_lpReadImageHead malloc %d Bytes\n",
|
||||
g_dwImageBufferSize);
|
||||
g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize);
|
||||
if (g_lpReadImageHead == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC,
|
||||
"Reflective_PrepareScan: g_lpReadImageHead malloc error \n");
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case CM_GRAY8ext:
|
||||
g_wtheReadyLines = g_wPixelDistance;
|
||||
DBG (DBG_FUNC, "Reflective_PrepareScan:g_wtheReadyLines=%d\n",
|
||||
g_wtheReadyLines);
|
||||
|
||||
DBG (DBG_FUNC,
|
||||
"Reflective_PrepareScan:g_lpReadImageHead malloc %d Bytes\n",
|
||||
g_dwImageBufferSize);
|
||||
g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize);
|
||||
if (g_lpReadImageHead == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC,
|
||||
"Reflective_PrepareScan: g_lpReadImageHead malloc error \n");
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case CM_TEXT:
|
||||
g_wtheReadyLines = g_wPixelDistance;
|
||||
DBG (DBG_FUNC, "Reflective_PrepareScan:g_wtheReadyLines=%d\n",
|
||||
g_wtheReadyLines);
|
||||
|
||||
DBG (DBG_FUNC,
|
||||
"Reflective_PrepareScan:g_lpReadImageHead malloc %d Bytes\n",
|
||||
g_dwImageBufferSize);
|
||||
g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize);
|
||||
if (g_lpReadImageHead == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC,
|
||||
"Reflective_PrepareScan: g_lpReadImageHead malloc error \n");
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Asic_ScanStart (&g_chip);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Get the data of image
|
||||
Parameters:
|
||||
lpBlock: the data of image
|
||||
Rows: the rows of image
|
||||
isOrderInvert: the RGB order
|
||||
Return value:
|
||||
TRUE if the operation is success, FALSE otherwise
|
||||
***********************************************************************/
|
||||
static SANE_Bool
|
||||
Reflective_GetRows (SANE_Byte * lpBlock, unsigned short * Rows, SANE_Bool isOrderInvert)
|
||||
{
|
||||
DBG (DBG_FUNC, "Reflective_GetRows: call in \n");
|
||||
if (!g_bOpened)
|
||||
{
|
||||
DBG (DBG_FUNC, "Reflective_GetRows: scanner not opened \n");
|
||||
return FALSE;
|
||||
}
|
||||
if (!g_bPrepared)
|
||||
{
|
||||
DBG (DBG_FUNC, "Reflective_GetRows: scanner not prepared \n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (g_ScanMode)
|
||||
{
|
||||
case CM_RGB48:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetRgb48BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetRgb48BitLine (lpBlock, isOrderInvert, Rows);
|
||||
|
||||
case CM_RGB24ext:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetRgb24BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetRgb24BitLine (lpBlock, isOrderInvert, Rows);
|
||||
|
||||
case CM_GRAY16ext:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetMono16BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetMono16BitLine (lpBlock, isOrderInvert, Rows);
|
||||
|
||||
case CM_GRAY8ext:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetMono8BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetMono8BitLine (lpBlock, isOrderInvert, Rows);
|
||||
|
||||
case CM_TEXT:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetMono1BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetMono1BitLine (lpBlock, isOrderInvert, Rows);
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DBG (DBG_FUNC, "Reflective_GetRows: leave Reflective_GetRows \n");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -47,16 +47,12 @@
|
|||
|
||||
|
||||
static SANE_Bool Transparent_Reset (void);
|
||||
static SANE_Bool Transparent_ScanSuggest (PTARGETIMAGE pTarget, PSUGGESTSETTING pSuggest);
|
||||
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_StopScan (void);
|
||||
static SANE_Bool Transparent_GetRows (SANE_Byte * lpBlock, unsigned short * Rows, SANE_Bool isOrderInvert);
|
||||
static SANE_Bool Transparent_AdjustAD (void);
|
||||
static SANE_Bool Transparent_FindTopLeft (unsigned short * lpwStartX, unsigned short * lpwStartY);
|
||||
static SANE_Bool Transparent_LineCalibration16Bits (unsigned short wTAShadingMinus);
|
||||
static SANE_Bool Transparent_PrepareScan (void);
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -120,152 +116,6 @@ Transparent_Reset (void)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
get suggest parameter of scaning
|
||||
Parameters:
|
||||
pTarget: the information of scaning
|
||||
pSuggest: the suggest parameter of scaning
|
||||
Return value:
|
||||
TRUE if operation is success, FALSE otherwise
|
||||
***********************************************************************/
|
||||
static SANE_Bool
|
||||
Transparent_ScanSuggest (PTARGETIMAGE pTarget, PSUGGESTSETTING pSuggest)
|
||||
{
|
||||
unsigned short wMaxWidth, wMaxHeight;
|
||||
int i;
|
||||
|
||||
DBG (DBG_FUNC, "Transparent_ScanSuggest: call in\n");
|
||||
|
||||
for (i = 0; s_wOpticalDpi[i] != 0; i++)
|
||||
{
|
||||
if (s_wOpticalDpi[i] <= pTarget->wDpi)
|
||||
{
|
||||
pSuggest->wYDpi = s_wOpticalDpi[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (s_wOpticalDpi[i] == 0)
|
||||
{
|
||||
i--;
|
||||
pSuggest->wYDpi = s_wOpticalDpi[i];
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
i--;
|
||||
pSuggest->wXDpi = s_wOpticalDpi[i];
|
||||
}
|
||||
|
||||
pSuggest->wX =
|
||||
(unsigned short) (((unsigned int) (pTarget->wX) * (unsigned int) (pSuggest->wXDpi)) /
|
||||
(unsigned int) (pTarget->wDpi));
|
||||
pSuggest->wY =
|
||||
(unsigned short) (((unsigned int) (pTarget->wY) * (unsigned int) (pSuggest->wYDpi)) /
|
||||
(unsigned int) (pTarget->wDpi));
|
||||
pSuggest->wWidth =
|
||||
(unsigned short) (((unsigned int) (pTarget->wWidth) * (unsigned int) (pSuggest->wXDpi)) /
|
||||
(unsigned int) (pTarget->wDpi));
|
||||
pSuggest->wHeight =
|
||||
(unsigned short) (((unsigned int) (pTarget->wHeight) * (unsigned int) (pSuggest->wYDpi)) /
|
||||
(unsigned int) (pTarget->wDpi));
|
||||
|
||||
pSuggest->wWidth = (pSuggest->wWidth / 2) * 2;
|
||||
|
||||
if (pTarget->cmColorMode == CM_TEXT)
|
||||
{
|
||||
pSuggest->wWidth = ((pSuggest->wWidth + 7) >> 3) << 3;
|
||||
if (pSuggest->wWidth < 8)
|
||||
pSuggest->wWidth = 8;
|
||||
}
|
||||
|
||||
g_Width = ((pSuggest->wWidth + 15) >> 4) << 4; /* Real Scan Width */
|
||||
g_Height = pSuggest->wHeight;
|
||||
|
||||
wMaxWidth = (MAX_SCANNING_WIDTH * pSuggest->wXDpi) / 300;
|
||||
wMaxHeight = (MAX_SCANNING_HEIGHT * pSuggest->wYDpi) / 300;
|
||||
|
||||
if (pTarget->cmColorMode == CM_TEXT)
|
||||
wMaxWidth = (wMaxWidth >> 3) << 3;
|
||||
|
||||
if (pSuggest->wWidth > wMaxWidth)
|
||||
pSuggest->wWidth = wMaxWidth;
|
||||
if (pSuggest->wHeight > wMaxHeight)
|
||||
pSuggest->wHeight = wMaxHeight;
|
||||
|
||||
if (pTarget->isOptimalSpeed)
|
||||
{
|
||||
DBG (DBG_FUNC, "Transparent_ScanSuggest: isOptimalSpeed is true\n");
|
||||
|
||||
switch (pTarget->cmColorMode)
|
||||
{
|
||||
case CM_RGB48:
|
||||
pSuggest->cmScanMode = CM_RGB48;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 6);
|
||||
break;
|
||||
case CM_RGB24:
|
||||
pSuggest->cmScanMode = CM_RGB24ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 3);
|
||||
break;
|
||||
|
||||
case CM_GRAY16:
|
||||
pSuggest->cmScanMode = CM_GRAY16ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 2);
|
||||
break;
|
||||
case CM_GRAY8:
|
||||
pSuggest->cmScanMode = CM_GRAY8ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth));
|
||||
break;
|
||||
case CM_TEXT:
|
||||
pSuggest->cmScanMode = CM_TEXT;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) (pSuggest->wWidth) / 8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG (DBG_FUNC, "Transparent_ScanSuggest: isOptimalSpeed not true\n");
|
||||
|
||||
switch (pTarget->cmColorMode)
|
||||
{
|
||||
case CM_RGB48:
|
||||
pSuggest->cmScanMode = CM_RGB48;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 6);
|
||||
break;
|
||||
case CM_RGB24:
|
||||
pSuggest->cmScanMode = CM_RGB24ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 3);
|
||||
break;
|
||||
case CM_GRAY16:
|
||||
pSuggest->cmScanMode = CM_GRAY16ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 2);
|
||||
break;
|
||||
case CM_GRAY8:
|
||||
pSuggest->cmScanMode = CM_GRAY8ext;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth));
|
||||
break;
|
||||
case CM_TEXT:
|
||||
pSuggest->cmScanMode = CM_TEXT;
|
||||
pSuggest->dwBytesPerRow = (unsigned int) (pSuggest->wWidth) / 8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DBG (DBG_FUNC, "Transparent_ScanSuggest: leave Transparent_ScanSuggest\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
setup scanning process
|
||||
Parameters:
|
||||
|
@ -467,106 +317,7 @@ Transparent_SetupScan (COLORMODE ColorMode, unsigned short XDpi, unsigned short
|
|||
g_Height);
|
||||
|
||||
DBG (DBG_FUNC, "Transparent_SetupScan: leave Transparent_SetupScan\n");
|
||||
return Transparent_PrepareScan ();
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Stop scan
|
||||
Return value:
|
||||
TRUE if operation is success, FALSE otherwise
|
||||
***********************************************************************/
|
||||
static SANE_Bool
|
||||
Transparent_StopScan (void)
|
||||
{
|
||||
DBG (DBG_FUNC, "Transparent_StopScan: call in\n");
|
||||
|
||||
if (!g_bOpened)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!g_bPrepared)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_isCanceled = TRUE;
|
||||
|
||||
pthread_cancel (g_threadid_readimage);
|
||||
pthread_join (g_threadid_readimage, NULL);
|
||||
|
||||
DBG (DBG_FUNC, "Transparent_StopScan: thread exit\n");
|
||||
|
||||
Asic_ScanStop (&g_chip);
|
||||
Asic_Close (&g_chip);
|
||||
g_bOpened = FALSE;
|
||||
|
||||
DBG (DBG_FUNC, "Transparent_StopScan: leave Transparent_StopScan\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Get the data of image
|
||||
Parameters:
|
||||
lpBlock: the data of image
|
||||
Rows: the rows of image
|
||||
isOrderInvert: the RGB order
|
||||
Return value:
|
||||
TRUE if the operation is success, FALSE otherwise
|
||||
***********************************************************************/
|
||||
static SANE_Bool
|
||||
Transparent_GetRows (SANE_Byte * lpBlock, unsigned short * Rows, SANE_Bool isOrderInvert)
|
||||
{
|
||||
DBG (DBG_FUNC, "Transparent_GetRows: call in\n");
|
||||
|
||||
if (!g_bOpened)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!g_bPrepared)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (g_ScanMode)
|
||||
{
|
||||
case CM_RGB48:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetRgb48BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetRgb48BitLine (lpBlock, isOrderInvert, Rows);
|
||||
|
||||
case CM_RGB24ext:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetRgb24BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetRgb24BitLine (lpBlock, isOrderInvert, Rows);
|
||||
|
||||
case CM_GRAY16ext:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetMono16BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetMono16BitLine (lpBlock, isOrderInvert, Rows);
|
||||
|
||||
case CM_GRAY8ext:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetMono8BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetMono8BitLine (lpBlock, isOrderInvert, Rows);
|
||||
|
||||
case CM_TEXT:
|
||||
if (g_XDpi == 1200)
|
||||
return MustScanner_GetMono1BitLine1200DPI (lpBlock, isOrderInvert,
|
||||
Rows);
|
||||
else
|
||||
return MustScanner_GetMono1BitLine (lpBlock, isOrderInvert, Rows);
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
return MustScanner_PrepareScan ();
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -1595,87 +1346,3 @@ Transparent_LineCalibration16Bits (unsigned short wTAShadingMinus)
|
|||
"Transparent_LineCalibration16Bits: leave Transparent_LineCalibration16Bits\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Prepare scan image
|
||||
Return value:
|
||||
TRUE if operation is success, FALSE otherwise
|
||||
***********************************************************************/
|
||||
static SANE_Bool
|
||||
Transparent_PrepareScan (void)
|
||||
{
|
||||
DBG (DBG_FUNC, "Transparent_PrepareScan: call in\n");
|
||||
|
||||
g_wScanLinesPerBlock = g_dwBufferSize / g_BytesPerRow;
|
||||
g_wMaxScanLines = g_dwImageBufferSize / g_BytesPerRow;
|
||||
g_wMaxScanLines =
|
||||
(g_wMaxScanLines / g_wScanLinesPerBlock) * g_wScanLinesPerBlock;
|
||||
g_isCanceled = FALSE;
|
||||
|
||||
g_dwScannedTotalLines = 0;
|
||||
g_wtheReadyLines = 0;
|
||||
|
||||
switch (g_ScanMode)
|
||||
{
|
||||
|
||||
case CM_RGB48:
|
||||
|
||||
g_wtheReadyLines = g_wLineDistance * 2 + g_wPixelDistance;
|
||||
|
||||
g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize);
|
||||
if (g_lpReadImageHead == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC, "Transparent_PrepareScan:malloc fail\n");
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case CM_RGB24ext:
|
||||
g_wtheReadyLines = g_wLineDistance * 2 + g_wPixelDistance;
|
||||
g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize);
|
||||
|
||||
if (g_lpReadImageHead == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC, "Transparent_PrepareScan:malloc fail\n");
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case CM_GRAY16ext:
|
||||
g_wtheReadyLines = g_wPixelDistance;
|
||||
g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize);
|
||||
if (g_lpReadImageHead == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC, "Transparent_PrepareScan:malloc fail\n");
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case CM_GRAY8ext:
|
||||
g_wtheReadyLines = g_wPixelDistance;
|
||||
g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize);
|
||||
if (g_lpReadImageHead == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC, "Transparent_PrepareScan:malloc fail\n");
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case CM_TEXT:
|
||||
g_wtheReadyLines = g_wPixelDistance;
|
||||
g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize);
|
||||
if (g_lpReadImageHead == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC, "Transparent_PrepareScan:malloc fail\n");
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Asic_ScanStart (&g_chip);
|
||||
|
||||
DBG (DBG_FUNC, "Transparent_PrepareScan: leave Transparent_PrepareScan\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue