Aquiring Image from Twain Device

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Aquiring Image from Twain Device

#1 Post 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

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Aquiring Image from Twain Device

#2 Post by rdonnay »

Try using TWAIN_AcquireToClipboard().

Code: Select all

DLLFUNCTION TWAIN_AcquireToClipboard(hWnd,nPixTypes) USING STDCALL FROM eztw32.dll
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Re: Aquiring Image from Twain Device

#3 Post by unixkd »

TWAIN_AcquireToClipboard()

Does not exist.

Thanks

bwolfsohn
Posts: 649
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: Aquiring Image from Twain Device

#4 Post by bwolfsohn »

unixkd wrote:TWAIN_AcquireToClipboard()

Does not exist.

Thanks
from _dcfunct.prg

DLLFUNCTION TWAIN_AcquireToClipboard(hWnd,nPixTypes) USING STDCALL FROM eztw32.dll
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Aquiring Image from Twain Device

#5 Post 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!

User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Re: Aquiring Image from Twain Device

#6 Post 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

Koverhage
Posts: 151
Joined: Mon Feb 01, 2010 8:45 am

Re: Aquiring Image from Twain Device

#7 Post 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
Klaus

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Aquiring Image from Twain Device

#8 Post 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.
The eXpress train is coming - and it has more cars.

Post Reply