Page 1 of 1

Aquiring Image from Twain Device

Posted: Thu Mar 02, 2017 7:11 am
by unixkd
Hi Roger/All

I want to acquire image from a webcam using EZTwain Pro dll.

Local oT := EZ_Twain(), hDIB, nFileSize := 0, cFile := "C:\10Tec\ppsphoto.jpg", nImageHandle, nReply
IF TWAIN_OpenSource( "InPhoto ID WebCam" ) == 1
nImageHandle := TWAIN_AcquireNative(0,0)
nReply := TWAIN_WriteNativeToFilename(nImageHandle,cFile)
oBitMap:LoadFile(cFile)
TWAIN_FreeNative(nImageHandle)
IF nReply == 0
DC_Winalert("image successfully written to file")
ELSE
DC_Winalert("something went wrong")
ENDIF
EndIf

***


The nImageHandle := TWAIN_AcquireNative(0,0) return the image handle - DIB

How can I save the acquired image to a BLOB field without first saving it to a graphic file ?

Joe

Re: Aquiring Image from Twain Device

Posted: Thu Mar 02, 2017 8:03 am
by rdonnay
Try using TWAIN_AcquireToClipboard().

Code: Select all

DLLFUNCTION TWAIN_AcquireToClipboard(hWnd,nPixTypes) USING STDCALL FROM eztw32.dll

Re: Aquiring Image from Twain Device

Posted: Thu Mar 02, 2017 8:46 am
by unixkd
TWAIN_AcquireToClipboard()

Does not exist.

Thanks

Re: Aquiring Image from Twain Device

Posted: Thu Mar 02, 2017 9:21 am
by bwolfsohn
unixkd wrote:TWAIN_AcquireToClipboard()

Does not exist.

Thanks
from _dcfunct.prg

DLLFUNCTION TWAIN_AcquireToClipboard(hWnd,nPixTypes) USING STDCALL FROM eztw32.dll

Re: Aquiring Image from Twain Device

Posted: Thu Mar 02, 2017 11:21 am
by Eugene Lutsenko
In _dcfunct.prg a lot of similar functions (DLLFUNCTION).
I'd like to know what they are doing!
In my opinion there still hides many treasures!

Re: Aquiring Image from Twain Device

Posted: Fri Mar 03, 2017 3:26 am
by unixkd
Thanks. Work Fine.

How can i get the size of the image contained in a bitmap object without saving it to a filename ?

Something like GetBitmapSize(oBtimap) ---> nBytes

Thanks

Joe

Re: Aquiring Image from Twain Device

Posted: Fri Mar 03, 2017 7:27 am
by Koverhage
Why not use this ?

Code: Select all

// ---------------------------------------------------------------------------------
// int      EZTAPI DIB_Width(HANDLE hdib);
// Width of DIB, in pixels (columns)
// ---------------------------------------------------------------------------------
   function eztw32_DIB_Width(hDib)
   local nNop := DllCall(nEztwDll,DLL_STDCALL,"DIB_Width", hDib)
   #ifdef TESTMODE
      msgbox("Width of DIB in pixels (columns): "+str(nNop),"DIB_Width")
   #endif
   return nNop

// ---------------------------------------------------------------------------------
// int      EZTAPI DIB_Height(HANDLE hdib);
// Height of DIB, in lines (rows)
// ---------------------------------------------------------------------------------
   function eztw32_DIB_Height(hDib)
   local nNol := DllCall(nEztwDll,DLL_STDCALL,"DIB_Height", hDib)
   #ifdef TESTMODE
      msgbox("Height of DIB in lines (rows): "+str(nNoL),"DIB_Height")
   #endif
   return nNol

Re: Aquiring Image from Twain Device

Posted: Fri Mar 03, 2017 7:38 am
by rdonnay
Another way to get the size is to save the clipboard to an XbpBitMap() object using :setBuffer().
The size will be in oBitmap:xSize and oBitmap:ySize.