2002-03-21 03:58:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2000 Corel Corporation
|
2006-02-21 15:41:07 +01:00
|
|
|
* Copyright 2006 CodeWeavers, Aric Stewart
|
2002-03-21 03:58:39 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-21 03:58:39 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-08-22 07:05:56 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
2002-03-21 03:58:39 +01:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "twain.h"
|
2006-05-08 20:05:42 +02:00
|
|
|
#include "sane_i.h"
|
2002-03-21 03:58:39 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(twain);
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_CIECOLOR/MSG_GET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_CIEColorGet (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_EXTIMAGEINFO/MSG_GET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_ExtImageInfoGet (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_GRAYRESPONSE/MSG_RESET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_GrayResponseReset (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_GRAYRESPONSE/MSG_SET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_GrayResponseSet (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_IMAGEFILEXFER/MSG_GET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_ImageFileXferGet (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_IMAGEINFO/MSG_GET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_ImageInfoGet (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
#ifndef HAVE_SANE
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
#else
|
|
|
|
TW_UINT16 twRC = TWRC_SUCCESS;
|
|
|
|
pTW_IMAGEINFO pImageInfo = (pTW_IMAGEINFO) pData;
|
|
|
|
SANE_Status status;
|
|
|
|
|
|
|
|
TRACE("DG_IMAGE/DAT_IMAGEINFO/MSG_GET\n");
|
|
|
|
|
2006-05-08 20:05:42 +02:00
|
|
|
if (activeDS.currentState != 6 && activeDS.currentState != 7)
|
2002-03-21 03:58:39 +01:00
|
|
|
{
|
|
|
|
twRC = TWRC_FAILURE;
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_SEQERROR;
|
2002-03-21 03:58:39 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-05-08 20:05:42 +02:00
|
|
|
if (activeDS.currentState == 6)
|
2002-03-21 03:58:39 +01:00
|
|
|
{
|
2004-09-14 21:31:22 +02:00
|
|
|
/* return general image description information about the image about to be transferred */
|
2007-03-14 19:10:03 +01:00
|
|
|
status = psane_get_parameters (activeDS.deviceHandle, &activeDS.sane_param);
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.sane_param_valid = TRUE;
|
2006-02-21 15:41:07 +01:00
|
|
|
TRACE("Getting parameters\n");
|
2002-03-21 03:58:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pImageInfo->XResolution.Whole = -1;
|
|
|
|
pImageInfo->XResolution.Frac = 0;
|
|
|
|
pImageInfo->YResolution.Whole = -1;
|
|
|
|
pImageInfo->YResolution.Frac = 0;
|
2006-05-08 20:05:42 +02:00
|
|
|
pImageInfo->ImageWidth = activeDS.sane_param.pixels_per_line;
|
|
|
|
pImageInfo->ImageLength = activeDS.sane_param.lines;
|
2006-02-21 15:41:07 +01:00
|
|
|
|
2006-05-08 20:05:42 +02:00
|
|
|
TRACE("Bits per Sample %i\n",activeDS.sane_param.depth);
|
|
|
|
TRACE("Frame Format %i\n",activeDS.sane_param.format);
|
2006-02-21 15:41:07 +01:00
|
|
|
|
2006-05-08 20:05:42 +02:00
|
|
|
if (activeDS.sane_param.format == SANE_FRAME_RGB )
|
2002-03-21 03:58:39 +01:00
|
|
|
{
|
2006-05-08 20:05:42 +02:00
|
|
|
pImageInfo->BitsPerPixel = activeDS.sane_param.depth * 3;
|
2006-02-21 15:41:07 +01:00
|
|
|
pImageInfo->Compression = TWCP_NONE;
|
2002-03-21 03:58:39 +01:00
|
|
|
pImageInfo->Planar = TRUE;
|
2006-02-21 15:41:07 +01:00
|
|
|
pImageInfo->SamplesPerPixel = 3;
|
2006-05-08 20:05:42 +02:00
|
|
|
pImageInfo->BitsPerSample[0] = activeDS.sane_param.depth;
|
|
|
|
pImageInfo->BitsPerSample[1] = activeDS.sane_param.depth;
|
|
|
|
pImageInfo->BitsPerSample[2] = activeDS.sane_param.depth;
|
2002-03-21 03:58:39 +01:00
|
|
|
pImageInfo->PixelType = TWPT_RGB;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2006-05-08 20:05:42 +02:00
|
|
|
else if (activeDS.sane_param.format == SANE_FRAME_GRAY)
|
2006-03-22 20:34:44 +01:00
|
|
|
{
|
2006-05-08 20:05:42 +02:00
|
|
|
pImageInfo->BitsPerPixel = activeDS.sane_param.depth;
|
2006-03-22 20:34:44 +01:00
|
|
|
pImageInfo->Compression = TWCP_NONE;
|
|
|
|
pImageInfo->Planar = TRUE;
|
|
|
|
pImageInfo->SamplesPerPixel = 1;
|
2006-05-08 20:05:42 +02:00
|
|
|
pImageInfo->BitsPerSample[0] = activeDS.sane_param.depth;
|
2006-03-22 20:34:44 +01:00
|
|
|
pImageInfo->PixelType = TWPT_GRAY;
|
|
|
|
}
|
2006-02-21 15:41:07 +01:00
|
|
|
else
|
2002-03-21 03:58:39 +01:00
|
|
|
{
|
2006-05-08 20:05:42 +02:00
|
|
|
ERR("Unhandled source frame type %i\n",activeDS.sane_param.format);
|
2006-02-21 15:41:07 +01:00
|
|
|
twRC = TWRC_FAILURE;
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_SEQERROR;
|
2002-03-21 03:58:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return twRC;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_IMAGELAYOUT/MSG_GET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_ImageLayoutGet (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_IMAGELAYOUT/MSG_GETDEFAULT */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_ImageLayoutGetDefault (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_IMAGELAYOUT/MSG_RESET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_ImageLayoutReset (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_IMAGELAYOUT/MSG_SET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_ImageLayoutSet (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_IMAGEMEMXFER/MSG_GET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_ImageMemXferGet (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
2006-02-21 15:41:07 +01:00
|
|
|
#ifndef HAVE_SANE
|
2002-03-21 03:58:39 +01:00
|
|
|
return TWRC_FAILURE;
|
2006-02-21 15:41:07 +01:00
|
|
|
#else
|
|
|
|
TW_UINT16 twRC = TWRC_SUCCESS;
|
|
|
|
pTW_IMAGEMEMXFER pImageMemXfer = (pTW_IMAGEMEMXFER) pData;
|
|
|
|
SANE_Status status = SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
TRACE ("DG_IMAGE/DAT_IMAGEMEMXFER/MSG_GET\n");
|
|
|
|
|
2006-05-08 20:05:42 +02:00
|
|
|
if (activeDS.currentState < 6 || activeDS.currentState > 7)
|
2006-02-21 15:41:07 +01:00
|
|
|
{
|
|
|
|
twRC = TWRC_FAILURE;
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_SEQERROR;
|
2006-02-21 15:41:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LPBYTE buffer;
|
|
|
|
int buff_len = 0;
|
|
|
|
int consumed_len = 0;
|
|
|
|
LPBYTE ptr;
|
|
|
|
int rows;
|
|
|
|
|
|
|
|
/* Transfer an image from the source to the application */
|
2006-05-08 20:05:42 +02:00
|
|
|
if (activeDS.currentState == 6)
|
2006-02-21 15:41:07 +01:00
|
|
|
{
|
2006-03-22 20:34:22 +01:00
|
|
|
|
|
|
|
/* trigger scanning dialog */
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.progressWnd = ScanningDialogBox(NULL,0);
|
2006-03-22 20:34:22 +01:00
|
|
|
|
2006-05-08 20:05:42 +02:00
|
|
|
ScanningDialogBox(activeDS.progressWnd,0);
|
2006-03-22 20:34:22 +01:00
|
|
|
|
2007-03-14 19:10:03 +01:00
|
|
|
status = psane_start (activeDS.deviceHandle);
|
2006-02-21 15:41:07 +01:00
|
|
|
if (status != SANE_STATUS_GOOD)
|
|
|
|
{
|
2007-03-14 19:10:03 +01:00
|
|
|
WARN("psane_start: %s\n", psane_strstatus (status));
|
|
|
|
psane_cancel (activeDS.deviceHandle);
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_OPERATIONERROR;
|
2006-02-21 15:41:07 +01:00
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
2007-03-14 19:10:03 +01:00
|
|
|
status = psane_get_parameters (activeDS.deviceHandle,
|
2006-05-08 20:05:42 +02:00
|
|
|
&activeDS.sane_param);
|
|
|
|
activeDS.sane_param_valid = TRUE;
|
2006-02-21 15:41:07 +01:00
|
|
|
|
|
|
|
if (status != SANE_STATUS_GOOD)
|
|
|
|
{
|
2007-03-14 19:10:03 +01:00
|
|
|
WARN("psane_get_parameters: %s\n", psane_strstatus (status));
|
|
|
|
psane_cancel (activeDS.deviceHandle);
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_OPERATIONERROR;
|
2006-02-21 15:41:07 +01:00
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Acquiring image %dx%dx%d bits (format=%d last=%d) from sane...\n"
|
2006-05-08 20:05:42 +02:00
|
|
|
, activeDS.sane_param.pixels_per_line, activeDS.sane_param.lines,
|
|
|
|
activeDS.sane_param.depth, activeDS.sane_param.format,
|
|
|
|
activeDS.sane_param.last_frame);
|
2006-02-21 15:41:07 +01:00
|
|
|
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.currentState = 7;
|
2006-02-21 15:41:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* access memory buffer */
|
2006-05-08 20:05:42 +02:00
|
|
|
if (pImageMemXfer->Memory.Length < activeDS.sane_param.bytes_per_line)
|
2006-02-21 15:41:07 +01:00
|
|
|
{
|
2007-03-14 19:10:03 +01:00
|
|
|
psane_cancel (activeDS.deviceHandle);
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_BADVALUE;
|
2006-02-21 15:41:07 +01:00
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pImageMemXfer->Memory.Flags & TWMF_HANDLE)
|
|
|
|
{
|
|
|
|
FIXME("Memory Handle, may not be locked correctly\n");
|
|
|
|
buffer = LocalLock(pImageMemXfer->Memory.TheMem);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
buffer = pImageMemXfer->Memory.TheMem;
|
|
|
|
|
|
|
|
memset(buffer,0,pImageMemXfer->Memory.Length);
|
|
|
|
|
|
|
|
ptr = buffer;
|
|
|
|
consumed_len = 0;
|
2006-05-08 20:05:42 +02:00
|
|
|
rows = pImageMemXfer->Memory.Length / activeDS.sane_param.bytes_per_line;
|
2006-02-21 15:41:07 +01:00
|
|
|
|
|
|
|
/* must fill full lines */
|
2006-05-08 20:05:42 +02:00
|
|
|
while (consumed_len < (activeDS.sane_param.bytes_per_line*rows) &&
|
2006-02-21 15:41:07 +01:00
|
|
|
status == SANE_STATUS_GOOD)
|
|
|
|
{
|
2007-03-14 19:10:03 +01:00
|
|
|
status = psane_read (activeDS.deviceHandle, ptr,
|
2006-05-08 20:05:42 +02:00
|
|
|
(activeDS.sane_param.bytes_per_line*rows) - consumed_len ,
|
2006-02-21 15:41:07 +01:00
|
|
|
&buff_len);
|
|
|
|
consumed_len += buff_len;
|
|
|
|
ptr += buff_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status == SANE_STATUS_GOOD || status == SANE_STATUS_EOF)
|
|
|
|
{
|
|
|
|
pImageMemXfer->Compression = TWCP_NONE;
|
2006-05-08 20:05:42 +02:00
|
|
|
pImageMemXfer->BytesPerRow = activeDS.sane_param.bytes_per_line;
|
|
|
|
pImageMemXfer->Columns = activeDS.sane_param.pixels_per_line;
|
2006-02-21 15:41:07 +01:00
|
|
|
pImageMemXfer->Rows = rows;
|
|
|
|
pImageMemXfer->XOffset = 0;
|
|
|
|
pImageMemXfer->YOffset = 0;
|
|
|
|
pImageMemXfer->BytesWritten = consumed_len;
|
|
|
|
|
2006-05-08 20:05:42 +02:00
|
|
|
ScanningDialogBox(activeDS.progressWnd, consumed_len);
|
2006-03-22 20:34:22 +01:00
|
|
|
|
2006-02-21 15:41:07 +01:00
|
|
|
if (status == SANE_STATUS_EOF)
|
|
|
|
{
|
2006-05-08 20:05:42 +02:00
|
|
|
ScanningDialogBox(activeDS.progressWnd, -1);
|
2007-03-14 19:10:03 +01:00
|
|
|
TRACE("psane_read: %s\n", psane_strstatus (status));
|
|
|
|
psane_cancel (activeDS.deviceHandle);
|
2006-02-21 15:41:07 +01:00
|
|
|
twRC = TWRC_XFERDONE;
|
|
|
|
}
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWRC_SUCCESS;
|
2006-02-21 15:41:07 +01:00
|
|
|
}
|
|
|
|
else if (status != SANE_STATUS_EOF)
|
|
|
|
{
|
2006-05-08 20:05:42 +02:00
|
|
|
ScanningDialogBox(activeDS.progressWnd, -1);
|
2007-03-14 19:10:03 +01:00
|
|
|
WARN("psane_read: %s\n", psane_strstatus (status));
|
|
|
|
psane_cancel (activeDS.deviceHandle);
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_OPERATIONERROR;
|
2006-02-21 15:41:07 +01:00
|
|
|
twRC = TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pImageMemXfer->Memory.Flags & TWMF_HANDLE)
|
|
|
|
LocalUnlock(pImageMemXfer->Memory.TheMem);
|
|
|
|
|
|
|
|
return twRC;
|
|
|
|
#endif
|
2002-03-21 03:58:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_IMAGENATIVEXFER/MSG_GET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_ImageNativeXferGet (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
#ifndef HAVE_SANE
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
#else
|
|
|
|
TW_UINT16 twRC = TWRC_SUCCESS;
|
|
|
|
pTW_UINT32 pHandle = (pTW_UINT32) pData;
|
|
|
|
SANE_Status status;
|
|
|
|
SANE_Byte buffer[32*1024];
|
|
|
|
int buff_len;
|
|
|
|
HBITMAP hDIB;
|
|
|
|
BITMAPINFO bmpInfo;
|
|
|
|
VOID *pBits;
|
|
|
|
HDC dc;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-03-21 03:58:39 +01:00
|
|
|
TRACE("DG_IMAGE/DAT_IMAGENATIVEXFER/MSG_GET\n");
|
|
|
|
|
2006-05-08 20:05:42 +02:00
|
|
|
if (activeDS.currentState != 6)
|
2002-03-21 03:58:39 +01:00
|
|
|
{
|
|
|
|
twRC = TWRC_FAILURE;
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_SEQERROR;
|
2002-03-21 03:58:39 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Transfer an image from the source to the application */
|
2007-03-14 19:10:03 +01:00
|
|
|
status = psane_start (activeDS.deviceHandle);
|
2002-03-21 03:58:39 +01:00
|
|
|
if (status != SANE_STATUS_GOOD)
|
|
|
|
{
|
2007-03-14 19:10:03 +01:00
|
|
|
WARN("psane_start: %s\n", psane_strstatus (status));
|
|
|
|
psane_cancel (activeDS.deviceHandle);
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_OPERATIONERROR;
|
2002-03-21 03:58:39 +01:00
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2007-03-14 19:10:03 +01:00
|
|
|
status = psane_get_parameters (activeDS.deviceHandle, &activeDS.sane_param);
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.sane_param_valid = TRUE;
|
2002-03-21 03:58:39 +01:00
|
|
|
if (status != SANE_STATUS_GOOD)
|
|
|
|
{
|
2007-03-14 19:10:03 +01:00
|
|
|
WARN("psane_get_parameters: %s\n", psane_strstatus (status));
|
|
|
|
psane_cancel (activeDS.deviceHandle);
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_OPERATIONERROR;
|
2002-03-21 03:58:39 +01:00
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Acquiring image %dx%dx%d bits (format=%d last=%d) from sane...\n"
|
2006-05-08 20:05:42 +02:00
|
|
|
, activeDS.sane_param.pixels_per_line, activeDS.sane_param.lines,
|
|
|
|
activeDS.sane_param.depth, activeDS.sane_param.format,
|
|
|
|
activeDS.sane_param.last_frame);
|
2002-03-21 03:58:39 +01:00
|
|
|
|
|
|
|
ZeroMemory (&bmpInfo, sizeof (BITMAPINFO));
|
|
|
|
bmpInfo.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
|
2006-05-08 20:05:42 +02:00
|
|
|
bmpInfo.bmiHeader.biWidth = activeDS.sane_param.pixels_per_line;
|
|
|
|
bmpInfo.bmiHeader.biHeight = activeDS.sane_param.lines;
|
2002-03-21 03:58:39 +01:00
|
|
|
bmpInfo.bmiHeader.biPlanes = 1;
|
2006-05-08 20:05:42 +02:00
|
|
|
bmpInfo.bmiHeader.biBitCount = activeDS.sane_param.depth;
|
2002-03-21 03:58:39 +01:00
|
|
|
bmpInfo.bmiHeader.biCompression = BI_RGB;
|
|
|
|
bmpInfo.bmiHeader.biSizeImage = 0;
|
|
|
|
bmpInfo.bmiHeader.biXPelsPerMeter = 0;
|
|
|
|
bmpInfo.bmiHeader.biYPelsPerMeter = 0;
|
|
|
|
bmpInfo.bmiHeader.biClrUsed = 1;
|
|
|
|
bmpInfo.bmiHeader.biClrImportant = 0;
|
|
|
|
bmpInfo.bmiColors[0].rgbBlue = 128;
|
|
|
|
bmpInfo.bmiColors[0].rgbGreen = 128;
|
|
|
|
bmpInfo.bmiColors[0].rgbRed = 128;
|
2006-05-08 20:05:42 +02:00
|
|
|
hDIB = CreateDIBSection ((dc = GetDC(activeDS.hwndOwner)), &bmpInfo,
|
2002-03-21 03:58:39 +01:00
|
|
|
DIB_RGB_COLORS, &pBits, 0, 0);
|
|
|
|
if (!hDIB)
|
|
|
|
{
|
2007-03-14 19:10:03 +01:00
|
|
|
psane_cancel (activeDS.deviceHandle);
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_LOWMEMORY;
|
2002-03-21 03:58:39 +01:00
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-03-21 03:58:39 +01:00
|
|
|
do
|
|
|
|
{
|
2007-03-14 19:10:03 +01:00
|
|
|
status = psane_read (activeDS.deviceHandle, buffer,
|
2002-03-21 03:58:39 +01:00
|
|
|
sizeof (buffer), &buff_len);
|
|
|
|
if (status == SANE_STATUS_GOOD)
|
|
|
|
{
|
2004-09-14 21:31:22 +02:00
|
|
|
/* FIXME: put code for converting the image data into DIB here */
|
2002-03-21 03:58:39 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
else if (status != SANE_STATUS_EOF)
|
|
|
|
{
|
2007-03-14 19:10:03 +01:00
|
|
|
WARN("psane_read: %s\n", psane_strstatus (status));
|
|
|
|
psane_cancel (activeDS.deviceHandle);
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_OPERATIONERROR;
|
2002-03-21 03:58:39 +01:00
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
} while (status == SANE_STATUS_GOOD);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2007-03-14 19:10:03 +01:00
|
|
|
psane_cancel (activeDS.deviceHandle);
|
2006-05-08 20:05:42 +02:00
|
|
|
ReleaseDC (activeDS.hwndOwner, dc);
|
2002-10-25 05:50:14 +02:00
|
|
|
*pHandle = (TW_UINT32)hDIB;
|
2002-06-01 01:06:46 +02:00
|
|
|
twRC = TWRC_XFERDONE;
|
2006-05-08 20:05:42 +02:00
|
|
|
activeDS.twCC = TWCC_SUCCESS;
|
|
|
|
activeDS.currentState = 7;
|
2002-03-21 03:58:39 +01:00
|
|
|
}
|
|
|
|
return twRC;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_GET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_JPEGCompressionGet (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_GETDEFAULT */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_JPEGCompressionGetDefault (pTW_IDENTITY pOrigin,
|
|
|
|
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_RESET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_JPEGCompressionReset (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_SET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_JPEGCompressionSet (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_PALETTE8/MSG_GET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_Palette8Get (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_PALETTE8/MSG_GETDEFAULT */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_Palette8GetDefault (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_PALETTE8/MSG_RESET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_Palette8Reset (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_PALETTE8/MSG_SET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_Palette8Set (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_RGBRESPONSE/MSG_RESET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_RGBResponseReset (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DG_IMAGE/DAT_RGBRESPONSE/MSG_SET */
|
2006-05-08 20:05:42 +02:00
|
|
|
TW_UINT16 SANE_RGBResponseSet (pTW_IDENTITY pOrigin,
|
2002-03-21 03:58:39 +01:00
|
|
|
TW_MEMREF pData)
|
|
|
|
{
|
|
|
|
FIXME ("stub!\n");
|
|
|
|
|
|
|
|
return TWRC_FAILURE;
|
|
|
|
}
|