ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

ds_image.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2000 Corel Corporation
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00017  */
00018 
00019 //#include "config.h"
00020 
00021 #include <stdarg.h>
00022 
00023 #include "windef.h"
00024 #include "winbase.h"
00025 #include "wingdi.h"
00026 #include "winuser.h"
00027 #include "twain.h"
00028 #include "twain_i.h"
00029 #include "wine/debug.h"
00030 
00031 WINE_DEFAULT_DEBUG_CHANNEL(twain);
00032 
00033 /* DG_IMAGE/DAT_CIECOLOR/MSG_GET */
00034 TW_UINT16 TWAIN_CIEColorGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00035                              TW_MEMREF pData)
00036 {
00037     FIXME ("stub!\n");
00038 
00039     return TWRC_FAILURE;
00040 }
00041 
00042 /* DG_IMAGE/DAT_EXTIMAGEINFO/MSG_GET */
00043 TW_UINT16 TWAIN_ExtImageInfoGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00044                                  TW_MEMREF pData)
00045 {
00046     FIXME ("stub!\n");
00047 
00048     return TWRC_FAILURE;
00049 }
00050 
00051 /* DG_IMAGE/DAT_GRAYRESPONSE/MSG_RESET */
00052 TW_UINT16 TWAIN_GrayResponseReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00053                                    TW_MEMREF pData)
00054 {
00055     FIXME ("stub!\n");
00056 
00057     return TWRC_FAILURE;
00058 }
00059 
00060 /* DG_IMAGE/DAT_GRAYRESPONSE/MSG_SET */
00061 TW_UINT16 TWAIN_GrayResponseSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00062                                  TW_MEMREF pData)
00063 {
00064     FIXME ("stub!\n");
00065 
00066     return TWRC_FAILURE;
00067 }
00068 
00069 /* DG_IMAGE/DAT_IMAGEFILEXFER/MSG_GET */
00070 TW_UINT16 TWAIN_ImageFileXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00071                                   TW_MEMREF pData)
00072 {
00073     FIXME ("stub!\n");
00074 
00075     return TWRC_FAILURE;
00076 }
00077 
00078 /* DG_IMAGE/DAT_IMAGEINFO/MSG_GET */
00079 TW_UINT16 TWAIN_ImageInfoGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00080                               TW_MEMREF pData)
00081 {
00082 #ifndef HAVE_SANE
00083     return TWRC_FAILURE;
00084 #else
00085     TW_UINT16 twRC = TWRC_SUCCESS;
00086     pTW_IMAGEINFO pImageInfo = (pTW_IMAGEINFO) pData;
00087     activeDS *pSource = TWAIN_LookupSource (pDest);
00088     SANE_Status status;
00089 
00090     TRACE("DG_IMAGE/DAT_IMAGEINFO/MSG_GET\n");
00091 
00092     if (!pSource)
00093     {
00094         twRC = TWRC_FAILURE;
00095         DSM_twCC = TWCC_BADDEST;
00096     }
00097     else if (pSource->currentState != 6 && pSource->currentState != 7)
00098     {
00099         twRC = TWRC_FAILURE;
00100         pSource->twCC = TWCC_SEQERROR;
00101     }
00102     else
00103     {
00104         if (pSource->currentState == 6)
00105         {
00106             /* return general image description information about the image about to be transfer */
00107             status = sane_get_parameters (pSource->deviceHandle, &pSource->sane_param);
00108         }
00109 
00110         pImageInfo->XResolution.Whole = -1;
00111         pImageInfo->XResolution.Frac = 0;
00112         pImageInfo->YResolution.Whole = -1;
00113         pImageInfo->YResolution.Frac = 0;
00114         pImageInfo->ImageWidth = pSource->sane_param.pixels_per_line;
00115         pImageInfo->ImageLength = pSource->sane_param.lines;
00116         if (pSource->sane_param.depth == 24)
00117         {
00118             pImageInfo->SamplesPerPixel = 3;
00119             pImageInfo->BitsPerSample[0] = 8;
00120             pImageInfo->BitsPerSample[1] = 8;
00121             pImageInfo->BitsPerSample[2] = 8;
00122             pImageInfo->BitsPerPixel = 24;
00123             pImageInfo->Planar = TRUE;
00124             pImageInfo->PixelType = TWPT_RGB;
00125             pImageInfo->Compression = TWCP_NONE;
00126         }
00127         else if (pSource->sane_param.depth == 8)
00128         {
00129             /* FIXME: fill the image info structure for 8-bit image */
00130         }
00131     }
00132 
00133     return twRC;
00134 #endif
00135 }
00136 
00137 /* DG_IMAGE/DAT_IMAGELAYOUT/MSG_GET */
00138 TW_UINT16 TWAIN_ImageLayoutGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00139                                 TW_MEMREF pData)
00140 {
00141     FIXME ("stub!\n");
00142 
00143     return TWRC_FAILURE;
00144 }
00145 
00146 /* DG_IMAGE/DAT_IMAGELAYOUT/MSG_GETDEFAULT */
00147 TW_UINT16 TWAIN_ImageLayoutGetDefault (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00148                                        TW_MEMREF pData)
00149 {
00150     FIXME ("stub!\n");
00151 
00152     return TWRC_FAILURE;
00153 }
00154 
00155 /* DG_IMAGE/DAT_IMAGELAYOUT/MSG_RESET */
00156 TW_UINT16 TWAIN_ImageLayoutReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00157                                   TW_MEMREF pData)
00158 {
00159     FIXME ("stub!\n");
00160 
00161     return TWRC_FAILURE;
00162 }
00163 
00164 /* DG_IMAGE/DAT_IMAGELAYOUT/MSG_SET */
00165 TW_UINT16 TWAIN_ImageLayoutSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00166                                 TW_MEMREF pData)
00167 {
00168     FIXME ("stub!\n");
00169 
00170     return TWRC_FAILURE;
00171 }
00172 
00173 /* DG_IMAGE/DAT_IMAGEMEMXFER/MSG_GET */
00174 TW_UINT16 TWAIN_ImageMemXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00175                                  TW_MEMREF pData)
00176 {
00177     FIXME ("stub!\n");
00178 
00179     return TWRC_FAILURE;
00180 }
00181 
00182 /* DG_IMAGE/DAT_IMAGENATIVEXFER/MSG_GET */
00183 TW_UINT16 TWAIN_ImageNativeXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00184                                     TW_MEMREF pData)
00185 {
00186 #ifndef HAVE_SANE
00187     return TWRC_FAILURE;
00188 #else
00189     TW_UINT16 twRC = TWRC_SUCCESS;
00190     pTW_UINT32 pHandle = (pTW_UINT32) pData;
00191     activeDS *pSource = TWAIN_LookupSource (pDest);
00192     SANE_Status status;
00193     SANE_Byte buffer[32*1024];
00194     int buff_len;
00195     HBITMAP hDIB;
00196     BITMAPINFO bmpInfo;
00197     VOID *pBits;
00198     HDC dc;
00199 
00200     TRACE("DG_IMAGE/DAT_IMAGENATIVEXFER/MSG_GET\n");
00201 
00202     if (!pSource)
00203     {
00204         twRC = TWRC_FAILURE;
00205         DSM_twCC = TWCC_NODS;
00206     }
00207     else if (pSource->currentState != 6)
00208     {
00209         twRC = TWRC_FAILURE;
00210         pSource->twCC = TWCC_SEQERROR;
00211     }
00212     else
00213     {
00214         /* Transfer an image from the source to the application */
00215         status = sane_start (pSource->deviceHandle);
00216         if (status != SANE_STATUS_GOOD)
00217         {
00218             WARN("sane_start: %s\n", sane_strstatus (status));
00219             sane_cancel (pSource->deviceHandle);
00220             pSource->twCC = TWCC_OPERATIONERROR;
00221             return TWRC_FAILURE;
00222         }
00223 
00224         status = sane_get_parameters (pSource->deviceHandle, &pSource->sane_param);
00225         if (status != SANE_STATUS_GOOD)
00226         {
00227             WARN("sane_get_parameters: %s\n", sane_strstatus (status));
00228             sane_cancel (pSource->deviceHandle);
00229             pSource->twCC = TWCC_OPERATIONERROR;
00230             return TWRC_FAILURE;
00231         }
00232 
00233         TRACE("Acquiring image %dx%dx%d bits (format=%d last=%d) from sane...\n"
00234               , pSource->sane_param.pixels_per_line, pSource->sane_param.lines,
00235               pSource->sane_param.depth, pSource->sane_param.format,
00236               pSource->sane_param.last_frame);
00237 
00238         ZeroMemory (&bmpInfo, sizeof (BITMAPINFO));
00239         bmpInfo.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
00240         bmpInfo.bmiHeader.biWidth = pSource->sane_param.pixels_per_line;
00241         bmpInfo.bmiHeader.biHeight = pSource->sane_param.lines;
00242         bmpInfo.bmiHeader.biPlanes = 1;
00243         bmpInfo.bmiHeader.biBitCount = pSource->sane_param.depth;
00244         bmpInfo.bmiHeader.biCompression = BI_RGB;
00245         bmpInfo.bmiHeader.biSizeImage = 0;
00246         bmpInfo.bmiHeader.biXPelsPerMeter = 0;
00247         bmpInfo.bmiHeader.biYPelsPerMeter = 0;
00248         bmpInfo.bmiHeader.biClrUsed = 1;
00249         bmpInfo.bmiHeader.biClrImportant = 0;
00250         bmpInfo.bmiColors[0].rgbBlue = 128;
00251         bmpInfo.bmiColors[0].rgbGreen = 128;
00252         bmpInfo.bmiColors[0].rgbRed = 128;
00253         hDIB = CreateDIBSection ((dc = GetDC(pSource->hwndOwner)), &bmpInfo,
00254                                  DIB_RGB_COLORS, &pBits, 0, 0);
00255         if (!hDIB)
00256         {
00257             sane_cancel (pSource->deviceHandle);
00258             pSource->twCC = TWCC_LOWMEMORY;
00259             return TWRC_FAILURE;
00260         }
00261 
00262         do
00263         {
00264             status = sane_read (pSource->deviceHandle, buffer,
00265                                 sizeof (buffer),  &buff_len);
00266             if (status == SANE_STATUS_GOOD)
00267             {
00268                 /* FIXME: put code for coverting the image data into DIB here */
00269 
00270             }
00271             else if (status != SANE_STATUS_EOF)
00272             {
00273                 WARN("sane_read: %s\n", sane_strstatus (status));
00274                 sane_cancel (pSource->deviceHandle);
00275                 pSource->twCC = TWCC_OPERATIONERROR;
00276                 return TWRC_FAILURE;
00277             }
00278         } while (status == SANE_STATUS_GOOD);
00279 
00280         sane_cancel (pSource->deviceHandle);
00281         ReleaseDC (pSource->hwndOwner, dc);
00282         *pHandle = (TW_UINT32)hDIB;
00283         twRC = TWRC_XFERDONE;
00284         pSource->twCC = TWCC_SUCCESS;
00285         pSource->currentState = 7;
00286     }
00287     return twRC;
00288 #endif
00289 }
00290 
00291 /* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_GET */
00292 TW_UINT16 TWAIN_JPEGCompressionGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00293                                     TW_MEMREF pData)
00294 {
00295     FIXME ("stub!\n");
00296 
00297     return TWRC_FAILURE;
00298 }
00299 
00300 /* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_GETDEFAULT */
00301 TW_UINT16 TWAIN_JPEGCompressionGetDefault (pTW_IDENTITY pOrigin,
00302                                            pTW_IDENTITY pDest,
00303                                            TW_MEMREF pData)
00304 {
00305     FIXME ("stub!\n");
00306 
00307     return TWRC_FAILURE;
00308 }
00309 
00310 /* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_RESET */
00311 TW_UINT16 TWAIN_JPEGCompressionReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00312                                       TW_MEMREF pData)
00313 {
00314     FIXME ("stub!\n");
00315 
00316     return TWRC_FAILURE;
00317 }
00318 
00319 /* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_SET */
00320 TW_UINT16 TWAIN_JPEGCompressionSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00321                                     TW_MEMREF pData)
00322 {
00323     FIXME ("stub!\n");
00324 
00325     return TWRC_FAILURE;
00326 }
00327 
00328 /* DG_IMAGE/DAT_PALETTE8/MSG_GET */
00329 TW_UINT16 TWAIN_Palette8Get (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00330                              TW_MEMREF pData)
00331 {
00332     FIXME ("stub!\n");
00333 
00334     return TWRC_FAILURE;
00335 }
00336 
00337 /* DG_IMAGE/DAT_PALETTE8/MSG_GETDEFAULT */
00338 TW_UINT16 TWAIN_Palette8GetDefault (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00339                                     TW_MEMREF pData)
00340 {
00341     FIXME ("stub!\n");
00342 
00343     return TWRC_FAILURE;
00344 }
00345 
00346 /* DG_IMAGE/DAT_PALETTE8/MSG_RESET */
00347 TW_UINT16 TWAIN_Palette8Reset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00348                                TW_MEMREF pData)
00349 {
00350     FIXME ("stub!\n");
00351 
00352     return TWRC_FAILURE;
00353 }
00354 
00355 /* DG_IMAGE/DAT_PALETTE8/MSG_SET */
00356 TW_UINT16 TWAIN_Palette8Set (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00357                              TW_MEMREF pData)
00358 {
00359     FIXME ("stub!\n");
00360 
00361     return TWRC_FAILURE;
00362 }
00363 
00364 /* DG_IMAGE/DAT_RGBRESPONSE/MSG_RESET */
00365 TW_UINT16 TWAIN_RGBResponseReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00366                                   TW_MEMREF pData)
00367 {
00368     FIXME ("stub!\n");
00369 
00370     return TWRC_FAILURE;
00371 }
00372 
00373 /* DG_IMAGE/DAT_RGBRESPONSE/MSG_SET */
00374 TW_UINT16 TWAIN_RGBResponseSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
00375                                 TW_MEMREF pData)
00376 {
00377     FIXME ("stub!\n");
00378 
00379     return TWRC_FAILURE;
00380 }

Generated on Sat May 26 2012 04:25:10 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.