kopia lustrzana https://gitlab.com/sane-project/backends
Remove redundant typecasts.
rodzic
cf6c88bfd1
commit
78863d13de
|
@ -597,7 +597,7 @@ SetParameters (LPSETPARAMETERS pSetParameters)
|
|||
double pow_d;
|
||||
double pow_z = (double) 10 / 16.0;
|
||||
|
||||
g_pGammaTable = (unsigned short *) malloc (sizeof (unsigned short) * 4096 * 3);
|
||||
g_pGammaTable = malloc (sizeof (unsigned short) * 4096 * 3);
|
||||
|
||||
DBG (DBG_INFO, "SetParameters: gamma table malloc %ld Bytes\n",
|
||||
(long int) sizeof (unsigned short) * 4096 * 3);
|
||||
|
@ -626,7 +626,7 @@ SetParameters (LPSETPARAMETERS pSetParameters)
|
|||
|| pSetParameters->cmColorMode == CM_RGB48)
|
||||
{
|
||||
unsigned int i, wGammaData;
|
||||
g_pGammaTable = (unsigned short *) malloc (sizeof (unsigned short) * 65536 * 3);
|
||||
g_pGammaTable = malloc (sizeof (unsigned short) * 65536 * 3);
|
||||
|
||||
if (g_pGammaTable == NULL)
|
||||
{
|
||||
|
@ -728,8 +728,8 @@ ReadScannedData (LPIMAGEROWS pImageRows)
|
|||
{
|
||||
SANE_Bool isRGBInvert;
|
||||
unsigned short Rows = 0;
|
||||
SANE_Byte *lpBlock = (SANE_Byte *) pImageRows->pBuffer;
|
||||
SANE_Byte *lpReturnData = (SANE_Byte *) pImageRows->pBuffer;
|
||||
SANE_Byte *lpBlock = pImageRows->pBuffer;
|
||||
SANE_Byte *lpReturnData = pImageRows->pBuffer;
|
||||
int i = 0;
|
||||
|
||||
DBG (DBG_FUNC, "ReadScannedData: start\n");
|
||||
|
@ -762,7 +762,7 @@ ReadScannedData (LPIMAGEROWS pImageRows)
|
|||
if (g_bIsFirstGetNegData)
|
||||
{
|
||||
unsigned int TotalImgeSize = g_SWHeight * g_ssSuggest.dwBytesPerRow;
|
||||
g_lpNegImageData = (SANE_Byte *) malloc (TotalImgeSize);
|
||||
g_lpNegImageData = malloc (TotalImgeSize);
|
||||
if (NULL != g_lpNegImageData)
|
||||
{
|
||||
SANE_Byte * lpTempData = g_lpNegImageData;
|
||||
|
@ -978,7 +978,7 @@ AutoLevel (SANE_Byte *lpSource, COLORMODE colorMode, unsigned short ScanLines,
|
|||
|
||||
unsigned int iWidth = BytesPerLine / 3;
|
||||
unsigned int iHeight = ScanLines;
|
||||
SANE_Byte *pbmpdata = (SANE_Byte *) lpSource;
|
||||
SANE_Byte *pbmpdata = lpSource;
|
||||
|
||||
unsigned int tmp = 0;
|
||||
unsigned short imin_threshold[3];
|
||||
|
@ -1022,9 +1022,9 @@ AutoLevel (SANE_Byte *lpSource, COLORMODE colorMode, unsigned short ScanLines,
|
|||
|
||||
for (i = 0; i < iWidth; i++)
|
||||
{
|
||||
R = (unsigned short) (SANE_Byte) * (pbmpdata + (tLines + i * 3 + 2));
|
||||
G = (unsigned short) (SANE_Byte) * (pbmpdata + (tLines + i * 3 + 1));
|
||||
B = (unsigned short) (SANE_Byte) * (pbmpdata + (tLines + i * 3));
|
||||
R = (unsigned short) *(pbmpdata + (tLines + i * 3 + 2));
|
||||
G = (unsigned short) *(pbmpdata + (tLines + i * 3 + 1));
|
||||
B = (unsigned short) *(pbmpdata + (tLines + i * 3));
|
||||
|
||||
max_R = _MAX (R, max_R);
|
||||
max_G = _MAX (G, max_G);
|
||||
|
@ -1142,9 +1142,9 @@ AutoLevel (SANE_Byte *lpSource, COLORMODE colorMode, unsigned short ScanLines,
|
|||
tLines = j * iWidth * 3;
|
||||
for (i = 0; i < iWidth; i++)
|
||||
{
|
||||
R = (unsigned short) (SANE_Byte) * (pbmpdata + (tLines + i * 3 + 2));
|
||||
G = (unsigned short) (SANE_Byte) * (pbmpdata + (tLines + i * 3 + 1));
|
||||
B = (unsigned short) (SANE_Byte) * (pbmpdata + (tLines + i * 3));
|
||||
R = (unsigned short) *(pbmpdata + (tLines + i * 3 + 2));
|
||||
G = (unsigned short) *(pbmpdata + (tLines + i * 3 + 1));
|
||||
B = (unsigned short) *(pbmpdata + (tLines + i * 3));
|
||||
|
||||
/*R*/ if (sum_R == 0)
|
||||
R = max_R;
|
||||
|
@ -1648,7 +1648,7 @@ sane_start (SANE_Handle handle)
|
|||
free (s->Scan_data_buf);
|
||||
s->Scan_data_buf = NULL;
|
||||
|
||||
s->Scan_data_buf = malloc (SCAN_BUFFER_SIZE * sizeof (SANE_Byte));
|
||||
s->Scan_data_buf = malloc (SCAN_BUFFER_SIZE);
|
||||
if (s->Scan_data_buf == NULL)
|
||||
return SANE_STATUS_NO_MEM;
|
||||
|
||||
|
@ -1707,20 +1707,18 @@ sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len,
|
|||
if (lines_to_read > s->read_rows)
|
||||
lines_to_read = s->read_rows;
|
||||
|
||||
tempbuf =
|
||||
(SANE_Byte *) malloc (sizeof (SANE_Byte) * lines_to_read *
|
||||
s->getpara.dwLineByteWidth + 3 * 1024 + 1);
|
||||
tempbuf = malloc (lines_to_read *
|
||||
s->getpara.dwLineByteWidth + 3 * 1024 + 1);
|
||||
memset (tempbuf, 0,
|
||||
sizeof (SANE_Byte) * lines_to_read * s->getpara.dwLineByteWidth +
|
||||
3 * 1024 + 1);
|
||||
lines_to_read * s->getpara.dwLineByteWidth + 3 * 1024 + 1);
|
||||
|
||||
DBG (DBG_INFO, "sane_read: buffer size is %ld\n",
|
||||
(long int) sizeof (SANE_Byte) * lines_to_read * s->getpara.dwLineByteWidth +
|
||||
(long int) lines_to_read * s->getpara.dwLineByteWidth +
|
||||
3 * 1024 + 1);
|
||||
|
||||
image_row.roRgbOrder = s->model.line_mode_color_order;
|
||||
image_row.wWantedLineNum = lines_to_read;
|
||||
image_row.pBuffer = (SANE_Byte *) tempbuf;
|
||||
image_row.pBuffer = tempbuf;
|
||||
s->bIsReading = SANE_TRUE;
|
||||
|
||||
if (!ReadScannedData (&image_row))
|
||||
|
|
|
@ -101,11 +101,11 @@ Mustek_ClearFIFO (PAsic chip)
|
|||
buf[1] = 0;
|
||||
buf[2] = 0;
|
||||
buf[3] = 0;
|
||||
status = WriteIOControl (chip, 0x05, 0, 4, (SANE_Byte *) (buf));
|
||||
status = WriteIOControl (chip, 0x05, 0, 4, buf);
|
||||
if (status != STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
status = WriteIOControl (chip, 0xc0, 0, 4, (SANE_Byte *) (buf));
|
||||
status = WriteIOControl (chip, 0xc0, 0, 4, buf);
|
||||
if (status != STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
|
@ -477,7 +477,7 @@ LLFRamAccess (PAsic chip, LLF_RAMACCESS * RamAccess)
|
|||
/* steal read 2 byte */
|
||||
usleep (20000);
|
||||
RamAccess->RwSize = 2;
|
||||
RamAccess->BufferPtr = (SANE_Byte *) a;
|
||||
RamAccess->BufferPtr = a;
|
||||
RamAccess->ReadWrite = READ_RAM;
|
||||
LLFRamAccess (chip, RamAccess);
|
||||
DBG (DBG_ASIC, "end steal 2 byte!\n");
|
||||
|
@ -3371,8 +3371,7 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
|
|||
double XRatioTypeDouble;
|
||||
double XRatioAdderDouble;
|
||||
|
||||
LLF_MOTORMOVE *lpMotorStepsTable =
|
||||
(LLF_MOTORMOVE *) malloc (sizeof (LLF_MOTORMOVE));
|
||||
LLF_MOTORMOVE lpMotorStepsTable;
|
||||
SANE_Byte byDummyCycleNum;
|
||||
unsigned short Total_MotorDPI;
|
||||
|
||||
|
@ -3400,16 +3399,9 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
|
|||
"wWidth=%d,wLength=%d\n",
|
||||
bScanBits, wXResolution, wYResolution, wX, wY, wWidth, wLength);
|
||||
|
||||
if (lpMotorStepsTable == NULL)
|
||||
{
|
||||
DBG (DBG_ERR, "Asic_SetWindow: lpMotorStepsTable == NULL\n");
|
||||
return STATUS_MEM_ERROR;
|
||||
}
|
||||
|
||||
if (chip->firmwarestate != FS_OPENED)
|
||||
{
|
||||
DBG (DBG_ERR, "Asic_SetWindow: Scanner is not opened\n");
|
||||
free (lpMotorStepsTable);
|
||||
return STATUS_INVAL;
|
||||
}
|
||||
|
||||
|
@ -3660,7 +3652,7 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
|
|||
EndSpeed =
|
||||
(unsigned short) ((dwLinePixelReport * wYResolution / Total_MotorDPI) /
|
||||
wMultiMotorStep);
|
||||
SetMotorStepTable (chip, lpMotorStepsTable, wY, dwTotalLineTheBufferNeed *
|
||||
SetMotorStepTable (chip, &lpMotorStepsTable, wY, dwTotalLineTheBufferNeed *
|
||||
Total_MotorDPI / wYResolution * wMultiMotorStep,
|
||||
wYResolution);
|
||||
|
||||
|
@ -3696,19 +3688,18 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
|
|||
Mustek_SendData (chip, ES01_FD_MotorFixedspeedLSB, LOBYTE (EndSpeed));
|
||||
Mustek_SendData (chip, ES01_FE_MotorFixedspeedMSB, HIBYTE (EndSpeed));
|
||||
|
||||
lpMotorTable = (unsigned short *) malloc (512 * 8 * 2);
|
||||
lpMotorTable = malloc (512 * 8 * 2);
|
||||
if (lpMotorTable == NULL)
|
||||
{
|
||||
DBG (DBG_ERR, "Asic_SetWindow: lpMotorTable == NULL\n");
|
||||
free (lpMotorStepsTable);
|
||||
return STATUS_MEM_ERROR;
|
||||
}
|
||||
memset (lpMotorTable, 0, 512 * 8 * sizeof (unsigned short));
|
||||
|
||||
CalMotorTable.StartSpeed = StartSpeed;
|
||||
CalMotorTable.EndSpeed = EndSpeed;
|
||||
CalMotorTable.AccStepBeforeScan = lpMotorStepsTable->wScanAccSteps;
|
||||
CalMotorTable.DecStepAfterScan = lpMotorStepsTable->bScanDecSteps;
|
||||
CalMotorTable.AccStepBeforeScan = lpMotorStepsTable.wScanAccSteps;
|
||||
CalMotorTable.DecStepAfterScan = lpMotorStepsTable.bScanDecSteps;
|
||||
CalMotorTable.lpMotorTable = lpMotorTable;
|
||||
|
||||
CalculateMotorTable (&CalMotorTable);
|
||||
|
@ -3768,7 +3759,7 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
|
|||
RamAccess.RwSize =
|
||||
ShadingTableSize ((int) ((wWidth + 4) * dbXRatioAdderDouble)) *
|
||||
sizeof (unsigned short);
|
||||
RamAccess.BufferPtr = (SANE_Byte *) chip->lpShadingTable;
|
||||
RamAccess.BufferPtr = chip->lpShadingTable;
|
||||
LLFRamAccess (chip, &RamAccess);
|
||||
|
||||
/* tell scan chip the shading table address, unit is 2^15 bytes */
|
||||
|
@ -3796,7 +3787,6 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
|
|||
Mustek_SendData (chip, ES01_02_ADAFEMuxConfig, 0x80);
|
||||
|
||||
free (lpMotorTable);
|
||||
free (lpMotorStepsTable);
|
||||
chip->firmwarestate = FS_OPENED;
|
||||
|
||||
DBG (DBG_ASIC, "Asic_SetWindow: Exit\n");
|
||||
|
@ -4046,7 +4036,7 @@ Asic_ReadCalibrationData (PAsic chip, void * pBuffer,
|
|||
if (bScanBits == 24)
|
||||
{
|
||||
unsigned int i;
|
||||
pCalBuffer = (SANE_Byte *) malloc (dwXferBytes);
|
||||
pCalBuffer = malloc (dwXferBytes);
|
||||
if (pCalBuffer == NULL)
|
||||
{
|
||||
DBG (DBG_ERR, "Asic_ReadCalibrationData: Can't malloc bCalBuffer " \
|
||||
|
@ -4059,8 +4049,7 @@ Asic_ReadCalibrationData (PAsic chip, void * pBuffer,
|
|||
dwReadImageData = (dwXferBytes - dwTotalReadData) < 65536 ?
|
||||
(dwXferBytes - dwTotalReadData) : 65536;
|
||||
|
||||
Mustek_DMARead (chip, dwReadImageData,
|
||||
(SANE_Byte *) (pCalBuffer + dwTotalReadData));
|
||||
Mustek_DMARead (chip, dwReadImageData, pCalBuffer + dwTotalReadData);
|
||||
dwTotalReadData += dwReadImageData;
|
||||
}
|
||||
|
||||
|
@ -4120,7 +4109,7 @@ Asic_MotorMove (PAsic chip, SANE_Bool isForward, unsigned int dwTotalSteps)
|
|||
|
||||
DBG (DBG_ASIC, "Asic_MotorMove: Enter\n");
|
||||
|
||||
NormalMoveMotorTable = (unsigned short *) malloc (512 * 8 * 2);
|
||||
NormalMoveMotorTable = malloc (512 * 8 * 2);
|
||||
if (NormalMoveMotorTable == NULL)
|
||||
{
|
||||
DBG (DBG_ASIC, "NormalMoveMotorTable == NULL\n");
|
||||
|
@ -4228,7 +4217,7 @@ Asic_SetShadingTable (PAsic chip, unsigned short * lpWhiteShading,
|
|||
|
||||
DBG (DBG_ASIC, "Allocating a new shading table, size=%d byte\n",
|
||||
wShadingTableSize);
|
||||
chip->lpShadingTable = (SANE_Byte *) malloc (wShadingTableSize);
|
||||
chip->lpShadingTable = malloc (wShadingTableSize);
|
||||
if (chip->lpShadingTable == NULL)
|
||||
{
|
||||
DBG (DBG_ASIC, "lpShadingTable == NULL\n");
|
||||
|
@ -4365,7 +4354,7 @@ Asic_SetCalibrate (PAsic chip, SANE_Byte bScanBits, unsigned short wXResolution,
|
|||
SANE_Byte byClear_Pulse_Width = 0;
|
||||
unsigned int dwLinePixelReport = 0;
|
||||
SANE_Byte byPHTG_PulseWidth, byPHTG_WaitWidth;
|
||||
unsigned short * lpMotorTable = (unsigned short *) malloc (512 * 8 * 2);
|
||||
unsigned short * lpMotorTable = malloc (512 * 8 * 2);
|
||||
unsigned int RealTableSize;
|
||||
unsigned short wFullBank;
|
||||
|
||||
|
|
|
@ -1859,7 +1859,7 @@ MustScanner_GetMono16BitLine1200DPI (SANE_Byte * lpLine,
|
|||
/* modify the last point */
|
||||
if (g_bIsFirstReadBefData)
|
||||
{
|
||||
g_lpBefLineImageData = (SANE_Byte *) malloc (g_SWBytesPerRow);
|
||||
g_lpBefLineImageData = malloc (g_SWBytesPerRow);
|
||||
if (NULL == g_lpBefLineImageData)
|
||||
{
|
||||
return FALSE;
|
||||
|
@ -2085,7 +2085,7 @@ MustScanner_GetMono8BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
|
|||
/* modify the last point */
|
||||
if (g_bIsFirstReadBefData)
|
||||
{
|
||||
g_lpBefLineImageData = (SANE_Byte *) malloc (g_SWBytesPerRow);
|
||||
g_lpBefLineImageData = malloc (g_SWBytesPerRow);
|
||||
if (NULL == g_lpBefLineImageData)
|
||||
{
|
||||
return FALSE;
|
||||
|
@ -2354,7 +2354,7 @@ MustScanner_CalculateMaxMin (SANE_Byte * pBuffer, unsigned short * lpMaxValue,
|
|||
|
||||
wResolution = wResolution;
|
||||
|
||||
wSecData = (unsigned short *) malloc (sizeof (unsigned short) * g_nSecNum);
|
||||
wSecData = malloc (sizeof (unsigned short) * g_nSecNum);
|
||||
if (wSecData == NULL)
|
||||
{
|
||||
return;
|
||||
|
@ -2381,8 +2381,7 @@ MustScanner_CalculateMaxMin (SANE_Byte * pBuffer, unsigned short * lpMaxValue,
|
|||
|
||||
free (wSecData);
|
||||
|
||||
wDarkSecData = (unsigned short *) malloc (sizeof (unsigned short) *
|
||||
g_nDarkSecNum);
|
||||
wDarkSecData = malloc (sizeof (unsigned short) * g_nDarkSecNum);
|
||||
if (wDarkSecData == NULL)
|
||||
{
|
||||
return;
|
||||
|
@ -2833,7 +2832,7 @@ MustScanner_PrepareScan (void)
|
|||
|
||||
DBG (DBG_FUNC, "MustScanner_PrepareScan: g_lpReadImageHead malloc %d bytes\n",
|
||||
g_dwImageBufferSize);
|
||||
g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize);
|
||||
g_lpReadImageHead = malloc (g_dwImageBufferSize);
|
||||
if (g_lpReadImageHead == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC, "MustScanner_PrepareScan: g_lpReadImageHead malloc " \
|
||||
|
|
|
@ -399,7 +399,7 @@ Reflective_AdjustAD (void)
|
|||
}
|
||||
wCalWidth = 10240;
|
||||
|
||||
lpCalData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * wCalWidth * 3);
|
||||
lpCalData = malloc (wCalWidth * 3);
|
||||
if (lpCalData == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC, "Reflective_AdjustAD: lpCalData malloc error\n");
|
||||
|
@ -420,7 +420,7 @@ Reflective_AdjustAD (void)
|
|||
Asic_ScanStop (&g_chip);
|
||||
|
||||
FILE *stream = NULL;
|
||||
SANE_Byte * lpBuf = (SANE_Byte *) malloc (50);
|
||||
SANE_Byte * lpBuf = malloc (50);
|
||||
if (NULL == lpBuf)
|
||||
{
|
||||
return FALSE;
|
||||
|
@ -429,8 +429,8 @@ Reflective_AdjustAD (void)
|
|||
|
||||
stream = fopen ("/root/AD(Ref).pnm\n", "wb+\n");
|
||||
sprintf (lpBuf, "P6\n%d %d\n255\n\n", wCalWidth, 1);
|
||||
fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream);
|
||||
fwrite (lpCalData, sizeof (SANE_Byte), wCalWidth * 3, stream);
|
||||
fwrite (lpBuf, 1, strlen (lpBuf), stream);
|
||||
fwrite (lpCalData, 1, wCalWidth * 3, stream);
|
||||
fclose (stream);
|
||||
free (lpBuf);
|
||||
#endif
|
||||
|
@ -903,7 +903,7 @@ Reflective_FindTopLeft (unsigned short * lpwStartX, unsigned short * lpwStartY)
|
|||
|
||||
wXResolution = wYResolution = FIND_LEFT_TOP_CALIBRATE_RESOLUTION;
|
||||
|
||||
lpCalData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * wCalWidth * wCalHeight);
|
||||
lpCalData = malloc (wCalWidth * wCalHeight);
|
||||
if (lpCalData == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC, "Reflective_FindTopLeft: lpCalData malloc error\n");
|
||||
|
@ -957,15 +957,15 @@ Reflective_FindTopLeft (unsigned short * lpwStartX, unsigned short * lpwStartY)
|
|||
#ifdef DEBUG_SAVE_IMAGE
|
||||
FILE *stream = NULL;
|
||||
stream = fopen ("/root/bound(Ref).pnm", "wb+\n");
|
||||
SANE_Byte * lpBuf = (SANE_Byte *) malloc (50);
|
||||
SANE_Byte * lpBuf = malloc (50);
|
||||
if (NULL == lpBuf)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
memset (lpBuf, 0, 50);
|
||||
sprintf (lpBuf, "P5\n%d %d\n255\n", wCalWidth, wCalHeight);
|
||||
fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream);
|
||||
fwrite (lpCalData, sizeof (SANE_Byte), wCalWidth * wCalHeight, stream);
|
||||
fwrite (lpBuf, 1, strlen (lpBuf), stream);
|
||||
fwrite (lpCalData, 1, wCalWidth * wCalHeight, stream);
|
||||
|
||||
fclose (stream);
|
||||
free (lpBuf);
|
||||
|
@ -1099,8 +1099,8 @@ Reflective_LineCalibration16Bits (void)
|
|||
|
||||
dwWhiteTotalSize = wCalWidth * wCalHeight * 3 * 2;
|
||||
dwDarkTotalSize = wCalWidth * wCalHeight * 3 * 2;
|
||||
lpWhiteData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * dwWhiteTotalSize);
|
||||
lpDarkData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * dwDarkTotalSize);
|
||||
lpWhiteData = malloc (dwWhiteTotalSize);
|
||||
lpDarkData = malloc (dwDarkTotalSize);
|
||||
|
||||
if (lpWhiteData == NULL || lpDarkData == NULL)
|
||||
{
|
||||
|
@ -1224,7 +1224,7 @@ Reflective_LineCalibration16Bits (void)
|
|||
|
||||
#ifdef DEBUG_SAVE_IMAGE
|
||||
FILE *stream = NULL;
|
||||
SANE_Byte * lpBuf = (SANE_Byte *) malloc (50);
|
||||
SANE_Byte * lpBuf = malloc (50);
|
||||
if (NULL == lpBuf)
|
||||
{
|
||||
return FALSE;
|
||||
|
@ -1233,30 +1233,30 @@ Reflective_LineCalibration16Bits (void)
|
|||
memset (lpBuf, 0, 50);
|
||||
stream = fopen ("/root/whiteshading(Ref).pnm", "wb+\n");
|
||||
sprintf (lpBuf, "P6\n%d %d\n65535\n", wCalWidth, wCalHeight);
|
||||
fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream);
|
||||
fwrite (lpWhiteData, sizeof (SANE_Byte), wCalWidth * wCalHeight * 3 * 2, stream);
|
||||
fwrite (lpBuf, 1, strlen (lpBuf), stream);
|
||||
fwrite (lpWhiteData, 1, wCalWidth * wCalHeight * 3 * 2, stream);
|
||||
fclose (stream);
|
||||
|
||||
memset (lpBuf, 0, 50);
|
||||
stream = fopen ("/root/darkshading(Ref).pnm", "wb+\n");
|
||||
sprintf (lpBuf, "P6\n%d %d\n65535\n", wCalWidth, wCalHeight);
|
||||
fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream);
|
||||
fwrite (lpDarkData, sizeof (SANE_Byte), wCalWidth * wCalHeight * 3 * 2, stream);
|
||||
fwrite (lpBuf, 1, strlen (lpBuf), stream);
|
||||
fwrite (lpDarkData, 1, wCalWidth * wCalHeight * 3 * 2, stream);
|
||||
fclose (stream);
|
||||
free (lpBuf);
|
||||
#endif
|
||||
|
||||
sleep (1);
|
||||
|
||||
lpWhiteShading = (unsigned short *) malloc (sizeof (unsigned short) * wCalWidth * 3);
|
||||
lpDarkShading = (unsigned short *) malloc (sizeof (unsigned short) * wCalWidth * 3);
|
||||
lpWhiteShading = malloc (sizeof (unsigned short) * wCalWidth * 3);
|
||||
lpDarkShading = malloc (sizeof (unsigned short) * wCalWidth * 3);
|
||||
|
||||
lpRWhiteSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpGWhiteSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpBWhiteSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpRDarkSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpGDarkSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpBDarkSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpRWhiteSort = malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpGWhiteSort = malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpBWhiteSort = malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpRDarkSort = malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpGDarkSort = malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpBDarkSort = malloc (sizeof (unsigned short) * wCalHeight);
|
||||
|
||||
if (lpWhiteShading == NULL || lpDarkShading == NULL
|
||||
|| lpRWhiteSort == NULL || lpGWhiteSort == NULL || lpBWhiteSort == NULL
|
||||
|
|
|
@ -382,7 +382,7 @@ Transparent_AdjustAD (void)
|
|||
|
||||
wCalWidth = 10240;
|
||||
|
||||
lpCalData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * wCalWidth * 3);
|
||||
lpCalData = malloc (wCalWidth * 3);
|
||||
if (lpCalData == NULL)
|
||||
{
|
||||
return FALSE;
|
||||
|
@ -402,7 +402,7 @@ Transparent_AdjustAD (void)
|
|||
Asic_ScanStop (&g_chip);
|
||||
|
||||
FILE *stream = NULL;
|
||||
SANE_Byte * lpBuf = (SANE_Byte *) malloc (50);
|
||||
SANE_Byte * lpBuf = malloc (50);
|
||||
if (NULL == lpBuf)
|
||||
{
|
||||
DBG (DBG_FUNC,
|
||||
|
@ -412,8 +412,8 @@ Transparent_AdjustAD (void)
|
|||
memset (lpBuf, 0, 50);
|
||||
stream = fopen ("/root/AD(Tra).pnm", "wb+\n");
|
||||
sprintf (lpBuf, "P6\n%d %d\n255\n", wCalWidth, 3);
|
||||
fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream);
|
||||
fwrite (lpCalData, sizeof (SANE_Byte), wCalWidth * 3, stream);
|
||||
fwrite (lpBuf, 1, strlen (lpBuf), stream);
|
||||
fwrite (lpCalData, 1, wCalWidth * 3, stream);
|
||||
fclose (stream);
|
||||
free (lpBuf);
|
||||
#endif
|
||||
|
@ -864,7 +864,7 @@ Transparent_FindTopLeft (unsigned short * lpwStartX, unsigned short * lpwStartY)
|
|||
wXResolution = wYResolution = FIND_LEFT_TOP_CALIBRATE_RESOLUTION;
|
||||
|
||||
|
||||
lpCalData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * wCalWidth * wCalHeight);
|
||||
lpCalData = malloc (wCalWidth * wCalHeight);
|
||||
if (lpCalData == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC, "Transparent_FindTopLeft: lpCalData malloc fail\n");
|
||||
|
@ -893,7 +893,7 @@ Transparent_FindTopLeft (unsigned short * lpwStartX, unsigned short * lpwStartY)
|
|||
|
||||
#ifdef DEBUG_SAVE_IMAGE
|
||||
FILE *stream = NULL;
|
||||
SANE_Byte * lpBuf = (SANE_Byte *) malloc (50);
|
||||
SANE_Byte * lpBuf = malloc (50);
|
||||
if (NULL == lpBuf)
|
||||
{
|
||||
return FALSE;
|
||||
|
@ -901,8 +901,8 @@ Transparent_FindTopLeft (unsigned short * lpwStartX, unsigned short * lpwStartY)
|
|||
memset (lpBuf, 0, 50);
|
||||
stream = fopen ("/root/bound(Tra).pnm", "wb+\n");
|
||||
sprintf (lpBuf, "P5\n%d %d\n255\n", wCalWidth, wCalHeight);
|
||||
fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream);
|
||||
fwrite (lpCalData, sizeof (SANE_Byte), wCalWidth * wCalHeight, stream);
|
||||
fwrite (lpBuf, 1, strlen (lpBuf), stream);
|
||||
fwrite (lpCalData, 1, wCalWidth * wCalHeight, stream);
|
||||
fclose (stream);
|
||||
free (lpBuf);
|
||||
#endif
|
||||
|
@ -1029,8 +1029,8 @@ Transparent_LineCalibration16Bits (unsigned short wTAShadingMinus)
|
|||
|
||||
dwWhiteTotalSize = wCalWidth * wCalHeight * 3 * 2;
|
||||
dwDarkTotalSize = wCalWidth * wCalHeight * 3 * 2;
|
||||
lpWhiteData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * dwWhiteTotalSize);
|
||||
lpDarkData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * dwDarkTotalSize);
|
||||
lpWhiteData = malloc (dwWhiteTotalSize);
|
||||
lpDarkData = malloc (dwDarkTotalSize);
|
||||
if (lpWhiteData == NULL || lpDarkData == NULL)
|
||||
{
|
||||
DBG (DBG_FUNC,
|
||||
|
@ -1070,7 +1070,7 @@ Transparent_LineCalibration16Bits (unsigned short wTAShadingMinus)
|
|||
|
||||
#ifdef DEBUG_SAVE_IMAGE
|
||||
FILE *stream = NULL;
|
||||
SANE_Byte * lpBuf = (SANE_Byte *) malloc (50);
|
||||
SANE_Byte * lpBuf = malloc (50);
|
||||
if (NULL == lpBuf)
|
||||
{
|
||||
return FALSE;
|
||||
|
@ -1078,28 +1078,28 @@ Transparent_LineCalibration16Bits (unsigned short wTAShadingMinus)
|
|||
memset (lpBuf, 0, 50);
|
||||
stream = fopen ("/root/whiteshading(Tra).pnm", "wb+\n");
|
||||
sprintf (lpBuf, "P6\n%d %d\n65535\n", wCalWidth, wCalHeight);
|
||||
fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream);
|
||||
fwrite (lpWhiteData, sizeof (SANE_Byte), wCalWidth * wCalHeight * 3 * 2, stream);
|
||||
fwrite (lpBuf, 1, strlen (lpBuf), stream);
|
||||
fwrite (lpWhiteData, 1, wCalWidth * wCalHeight * 3 * 2, stream);
|
||||
fclose (stream);
|
||||
|
||||
memset (lpBuf, 0, 50);
|
||||
stream = fopen ("/root/darkshading(Tra).pnm", "wb+\n");
|
||||
sprintf (lpBuf, "P6\n%d %d\n65535\n", wCalWidth * wCalHeight);
|
||||
fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream);
|
||||
fwrite (lpDarkData, sizeof (SANE_Byte), wCalWidth * wCalHeight * 3 * 2, stream);
|
||||
fwrite (lpBuf, 1, strlen (lpBuf), stream);
|
||||
fwrite (lpDarkData, 1, wCalWidth * wCalHeight * 3 * 2, stream);
|
||||
fclose (stream);
|
||||
free (lpBuf);
|
||||
#endif
|
||||
|
||||
lpWhiteShading = (unsigned short *) malloc (sizeof (unsigned short) * wCalWidth * 3);
|
||||
lpDarkShading = (unsigned short *) malloc (sizeof (unsigned short) * wCalWidth * 3);
|
||||
lpWhiteShading = malloc (sizeof (unsigned short) * wCalWidth * 3);
|
||||
lpDarkShading = malloc (sizeof (unsigned short) * wCalWidth * 3);
|
||||
|
||||
lpRWhiteSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpGWhiteSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpBWhiteSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpRDarkSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpGDarkSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpBDarkSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpRWhiteSort = malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpGWhiteSort = malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpBWhiteSort = malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpRDarkSort = malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpGDarkSort = malloc (sizeof (unsigned short) * wCalHeight);
|
||||
lpBDarkSort = malloc (sizeof (unsigned short) * wCalHeight);
|
||||
|
||||
if (lpWhiteShading == NULL || lpDarkShading == NULL
|
||||
|| lpRWhiteSort == NULL || lpGWhiteSort == NULL || lpBWhiteSort == NULL
|
||||
|
|
Ładowanie…
Reference in New Issue