Page 1 of 3

Clase TScanner - Interface de escaneo

PostPosted: Wed Sep 23, 2009 3:46 pm
by alvaro533
Hola,

Image

Usando la clase de Rafa Carmona TScan, he hecho un interface que permite seleccionar, arrastrando con el ratón, un cuadrado dentro de la imagen previa y escanear sólo esa parte. Luego, se puede crear un fichero pdf multipágina, con todas las páginas escaneadas. Las selecciones se guardan en un fichero ini para el siguiente uso.

Cada página que se escanea nos pide confirmación si la borramos o la añadimos al pdf que estamos creando. La compresión que se consigue es bastante buena.

Image


Image

Luego nos permite gestionar el directorio y el nombre del fichero desde el programa, para así asignar, por ejemplo, facturas escaneadas a un registro del una base de datos de facturas.

En breve subo un link con las fuentes. Para crear el pdf multipágina hago una llamada a nconvert, que es muy rápido y totalmente automático. nconvert es freeware para uso no comercial.
http://xnview.com/en/nconvert.html

Alvaro
p.s. Gracias a Rafael por compartir su clase.

Re: Clase TScanner

PostPosted: Wed Sep 23, 2009 4:03 pm
by Daniel Garcia-Gil
Alvaro...

Excelente.... ante magnifica exposicion y descripcion solo queda compartir en ejemplo funcional para saber como lo haces :mrgreen:

Re: Clase TScanner

PostPosted: Wed Sep 23, 2009 5:13 pm
by alvaro533
Aquí está:

http://www.box.net/shared/sov0hjb6t2

Basado en la clase de TScan de Rafael Carmona.

Compilar con el proyecto:

QScanner2.prg
TSCAN.prg (no usar la TSCAN.lib porque creo que he modificado algo en la clase de Rafael)
a_scan.prg
Taq_selearea.prg

con

QScanner2.rc (solo el icono)
Qscanner2.ch

y enlazar TWAIN.LIB

En el directorio de la apliación necesitamos:

EZTW32.dll
Freeimage.dll
nconvert.exe

Un saludo,

Alvaro

Re: Clase TScanner

PostPosted: Wed Sep 23, 2009 9:12 pm
by alvaro533
Se me olvidaba, el pdf mantiene el la escala del documento escaneado. Lo he tenido que hacer con nconvert, porque la clase del scanner no controlaba los DPI de la imagen. Es decir, si se imprime desde Adobe acrobat o Foxit con escala al 100%, se conserva en tamaño original del documento. Esto es útil si se escanean documentos con formatos pequeños.

Alvaro

Re: Clase TScanner - Interface de escaneo

PostPosted: Thu Sep 24, 2009 7:32 am
by Andrés González
Excelente contribución, muy buen trabajo Alvaro. Seguro que Rafa estará contento de que su clase este dando tan excelentes resultados. Enhorabuena a los dos.

Re: Clase TScanner - Interface de escaneo

PostPosted: Thu Sep 24, 2009 2:54 pm
by fespinoza
Alvaro

Estoy probando con tu ejemplo, enlazando a una aplicación mía, pero al compilar y enlazar tsacn.prg me sale este error repetido para todas las funciones harbour (creo). Incluí los 4 .prg y la libreria Twain.lib.

Code: Select all  Expand view
Compilado y Enlazado de: [C:\Sicef_xH\SicefWin.Exe]
Ejecución No. 6
Ejecutada a las: 09:43:12
============================================================
FATAL: No fué encontrado C:\Sicef_xH\Bin\SicefWin.RC
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Copyright 1999-2009, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'C:\Sicef_xH\Bin\tscan.prg'...
Lines 279, Functions/Procedures 8
Generating C source output to 'C:\Sicef_xH\Obj\tscan.hrb'...
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
C:\Sicef_xH\Obj\tscan.hrb:
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 296: Call to function
'TWAIN_Acquire' with no prototype in function HB_FUN_TW_ACQUIRE
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 322: Call to function
'TWAIN_AcquireMemory' with no prototype in function HB_FUN_TW_ACQUIREMEMORY
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 332: Call to function
'TWAIN_AcquireFile' with no prototype in function HB_FUN_TW_ACQUIREFILE
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 355: Call to function
'TWAIN_SourceName' with no prototype in function HB_FUN_TW_SOURCENAME
Error E2342 C:\\Sicef_xH\\Bin\\tscan.prg 355: Type mismatch in parameter
'szText' (wanted 'const signed char *', got 'int') in function
HB_FUN_TW_SOURCENAME
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 360: Call to function
'TWAIN_GetSourceName' with no prototype in function HB_FUN_TW_GETSOURCENAME
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 369: Call to function
'DIB_WriteToJpeg' with no prototype in function HB_FUN_TW_DIBWJPG
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 374: Call to function
'DIB_WriteToBmp' with no prototype in function HB_FUN_TW_DIBWBMP
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 382: Call to function
'TWAIN_IsJpegAvailable' with no prototype in function HB_FUN_TW_ISJPG
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 387: Call to function
'TWAIN_SetSaveFormat' with no prototype in function HB_FUN_TW_SETSAVEFORMAT
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 392: Call to function
'TWAIN_GetSaveFormat' with no prototype in function HB_FUN_TW_GETSAVEFORMAT
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 397: Call to function
'TWAIN_SetJpegQuality' with no prototype in function HB_FUN_TW_SETJPEGQUALITY
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 403: Call to function
'TWAIN_GetJpegQuality' with no prototype in function HB_FUN_TW_GETJPEGQUALITY
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 421: Call to function
'TWAIN_SetMultiTransfer' with no prototype in function
HB_FUN_TW_SETMULTITRANSFER
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 427: Call to function
'TWAIN_GetMultiTransfer' with no prototype in function
HB_FUN_TW_GETMULTITRANSFER
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 444: Call to function
'TWAIN_DisableParent' with no prototype in function HB_FUN_TW_DISABLEPARENT
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 450: Call to function
'TWAIN_GetDisableParent' with no prototype in function
HB_FUN_TW_GETDISABLEPARENT
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 464: Call to function
'TWAIN_SetAppTitle' with no prototype in function HB_FUN_TW_SETAPPTITLE
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 490: Call to function
'TWAIN_GetSourceList' with no prototype in function HB_FUN_TW_GETSOURCELIST
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 495: Call to function
'TWAIN_GetNextSourceName' with no prototype in function
HB_FUN_TW_GETNEXTSOURCENAME
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 500: Call to function
'TWAIN_GetDefaultSourceName' with no prototype in function
HB_FUN_TW_GETDEFAULTSOURCENAME
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 505: Call to function
'TWAIN_OpenSource' with no prototype in function HB_FUN_TW_OPENSOURCE
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 586: Call to function
'TWAIN_SetXResolution' with no prototype in function HB_FUN_TW_SETXRESOLUTION
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 591: Call to function
'TWAIN_SetYResolution' with no prototype in function HB_FUN_TW_SETYRESOLUTION
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 606: Call to function
'TWAIN_SetThreshold' with no prototype in function HB_FUN_TW_SETTHRESHOLD
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 611: Call to function
'TWAIN_GetCurrentThreshold' with no prototype in function
HB_FUN_TW_GETCURRENTTHRESHOLD
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 626: Call to function
'TWAIN_SupportsFileXfer' with no prototype in function
HB_FUN_TW_SUPPORTSFILEXFER
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 631: Call to function
'TWAIN_SetPaperSize' with no prototype in function HB_FUN_TW_SETPAPERSIZE
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 638: Call to function
'TWAIN_HasFeeder' with no prototype in function HB_FUN_TW_HASFEEDER
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 643: Call to function
'TWAIN_IsFeederSelected' with no prototype in function
HB_FUN_TW_ISFEEDERSELECTED
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 648: Call to function
'TWAIN_SelectFeeder' with no prototype in function HB_FUN_TW_SELECTFEEDER
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 653: Call to function
'TWAIN_IsAutoFeedOn' with no prototype in function HB_FUN_TW_ISAUTOFEEDON
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 658: Call to function
'TWAIN_SetAutoFeed' with no prototype in function HB_FUN_TW_SETAUTOFEDD
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 663: Call to function
'TWAIN_IsFeederLoaded' with no prototype in function HB_FUN_TW_ISFEEDERLOADED
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 669: Call to function
'TWAIN_GetDuplexSupport' with no prototype in function
HB_FUN_TW_GETDUPLEXSUPPORT
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 674: Call to function
'TWAIN_EnableDuplex' with no prototype in function HB_FUN_TW_ENABLEDUPLEX
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 679: Call to function
'TWAIN_IsDuplexEnabled' with no prototype in function HB_FUN_TW_ISDUPLEXENABLED
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 686: Call to function
'TWAIN_HasControllableUI' with no prototype in function
HB_FUN_TW_HASCONTROLLABLEUI
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 691: Call to function
'TWAIN_SetIndicators' with no prototype in function HB_FUN_TW_SETINDICATORS
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 696: Call to function
'TWAIN_Compression' with no prototype in function HB_FUN_TW_COMPRESSION
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 701: Call to function
'TWAIN_SetCompression' with no prototype in function HB_FUN_TW_SETCOMPRESSION
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 706: Call to function 'TWAIN_Tiled'
with no prototype in function HB_FUN_TW_TILED
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 711: Call to function
'TWAIN_SetTiled' with no prototype in function HB_FUN_TW_SETTILED
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 716: Call to function
'TWAIN_PlanarChunky' with no prototype in function HB_FUN_TW_PLANARCHUNKY
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 721: Call to function
'TWAIN_SetPlanarChunky' with no prototype in function HB_FUN_TW_SETPLANARCHUNKY
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 726: Call to function
'TWAIN_PixelFlavor' with no prototype in function HB_FUN_TW_PIXELFLAVOR
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 731: Call to function
'TWAIN_SetPixelFlavor' with no prototype in function HB_FUN_TW_SETPIXELFLAVOR
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 736: Call to function
'TWAIN_SetLightPath' with no prototype in function HB_FUN_TW_SETLIGHTPATH
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 741: Call to function
'TWAIN_SetAutoBright' with no prototype in function HB_FUN_TW_SETAUTOBRIGHT
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 746: Call to function
'TWAIN_SetGamma' with no prototype in function HB_FUN_TW_SETGAMMA
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 751: Call to function
'TWAIN_SetShadow' with no prototype in function HB_FUN_TW_SETSHADOW
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 756: Call to function
'TWAIN_SetHighlight' with no prototype in function HB_FUN_TW_SETHIGHLIGHT
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 763: Call to function
'TWAIN_SetImageLayout' with no prototype in function HB_FUN_TW_SETIMAGELAYOUT
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 768: Call to function
'TWAIN_ResetImageLayout' with no prototype in function
HB_FUN_TW_RESETIMAGELAYOUT
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 777: Call to function
'TWAIN_GetImageLayout' with no prototype in function HB_FUN_TW_GETIMAGELAYOUT
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 791: Call to function
'TWAIN_GetDefaultImageLayout' with no prototype in function
HB_FUN_TW_GETDEFAULTIMAGELAYOUT
Warning W8065 C:\\Sicef_xH\\Bin\\tscan.prg 803: Call to function
'DIB_GetFromClipboard' with no prototype in function
HB_FUN_TW_DIB_GETFROMCLIPBOARD
*** 1 errors in Compile ***
MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
** error 1 ** deleting C:\Sicef_xH\Obj\tscan.obj
Ha habido ERRORES al intentar Generar la Aplicacion
============================================================
VERCE v5.0+ -> Ver Resultados de Compilación y Enlazado v5.0+
Juan Carlos Salinas Ojeda
jcso@hotmail.com
Minatitlán, Veracruz. MEXICO
Y Solo Veracruz es bello !!!
William Morales [wmormar]
wmormar@yahoo.com.mx
Tabasco, tierra del eden mexicano
FiveWin for Harbour!!
 



Saludos

fernando Espinoza

Re: Clase TScanner - Interface de escaneo

PostPosted: Thu Sep 24, 2009 3:45 pm
by alvaro533
Hola Fernando,

Pues no te puedo decir. Las funciones a las que hace referencia el error son las que están contenidas en twain.lib. Yo uso Harbour, no lo he probado con XHarbour, pero debería funcionar.

Un saludo

Alvaro

Re: Clase TScanner - Interface de escaneo

PostPosted: Fri Sep 25, 2009 11:42 am
by thefull
Oh!!! Que grande! A ver si saco un tiempo y miro como implementaste la solución.

Re: Clase TScanner - Interface de escaneo

PostPosted: Fri Sep 25, 2009 6:49 pm
by jose_murugosa
Hola,

La verdad que la clase está excelente.

FELICITACIONES.

Como vi que algunos compañeros no pudieron compilarla apropiadamente, incluyo este archivo comprimido donde están los archivos .vrc (verce) para hacer la compilación y además un archivito .h que faltaba que pertenece a la clase de Rafa Carmona, y es necesario para compilar.

Espero sea de ayuda y sobre todo no sea mal interpretado.

Sea todo el crédito a sus autores.

http://www.box.net/shared/vhl11vvj47

Re: Clase TScanner - Interface de escaneo

PostPosted: Mon Sep 28, 2009 1:26 am
by fespinoza
Gracias a Thefull, Alvaro y José, ahora funciona perfecto y me es de gran utilidad.

Re: Clase TScanner - Interface de escaneo

PostPosted: Mon Sep 28, 2009 11:48 am
by alvaro533
thefull wrote:Oh!!! Que grande! A ver si saco un tiempo y miro como implementaste la solución.


Gracias Rafa por la clase original. No me había fijado que el nick "Thefull" eras tu.

Alvaro

Clase TScanner - Interface de escaneo - Jose Murugosa

PostPosted: Thu May 20, 2010 8:19 pm
by Enrrique Vertiz
Saludos Jose, hace algun tiempo subiste esta clase a internet con el ejemplo que hizo Alvaro, estoy tratando de bajarla de internet pero el Link al que hace referencia ya no es valido, podrias pr favor subirlo nuevamente o indicarme desde donde la puedo bajar, MUCHAS GRACIAS

Re: Clase TScanner - Interface de escaneo

PostPosted: Thu May 20, 2010 9:53 pm
by AIDA
se ve muy bonito :D

Gracias :mrgreen:

Saluditos :wink:

Re: Clase TScanner - Interface de escaneo

PostPosted: Fri May 21, 2010 12:19 am
by Bayron
Gracias Alvaro, Rafa, y a todos por compartir con nosotros su grandioso trabajo.

Yo al menos tengo mucho que agraceder a todo el foro, que de una u otra manera han contribuído para que yo vaya aprendiendo, y ejemplos como estos, nos facilitan la vida a los que no podemos tanto....

Re: Clase TScanner - Interface de escaneo

PostPosted: Fri May 21, 2010 1:17 am
by Ruben Fernandez
Excelente como siempre, Gracias Alvaro y Gracias Rafa.

Que seria de mi sin este foro........

Saludos Ruben Fernandez