Solved

Controlling Scanner

Posted on 2002-06-13
9
508 Views
Last Modified: 2013-12-27
Does anyone know if there is any ActiveX/OLE interface that is able to control a scanner.
I am trying to add scanning functionality to a Cobol program and my Cobol can use AxtiveX/OLE components and  call functions from a DLL library.
I know that there is TWAIN and ISIS interface for controlling scanners. Unfortunately ISIS (which is industry standard for high volume scanning) is not available as free trial. Therefore I am trying to use TWAIN. I am able to scan an image using TWAIN ActiveX control but it does not allow me to save the result to a file.

0
Comment
Question by:marianpancik
9 Comments
 
LVL 27

Expert Comment

by:Asta Cu
Comment Utility
0
 
LVL 27

Expert Comment

by:Asta Cu
Comment Utility
0
 
LVL 1

Expert Comment

by:mitchg
Comment Utility
If your TWAIN control returns a DIB handle, you can probably simply write out a .bmp file directly from COBOL.  The .bmp file format is apparently a simple header followed by the DIB contents.

What COBOL are you using?  Does your control return a DIB handle or ...?

Glenn
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:marianpancik
Comment Utility
I'm using Acucorp's AcuGT 5.2.0 (see http://www.acucorp.com) and my OLE component's documentation says that it returns the DIB HANDLE (OLE_HANDLE) but I have no idea how to get more information from it to be able to save it to file.
0
 
LVL 1

Accepted Solution

by:
mitchg earned 100 total points
Comment Utility
Here's some C code I picked up to write a DIB handle to a .bmp file:

Writing a bitmap to a bmp file is fairly simple if we have a handle to device-independent bitmap. we simply write bitmapinfoheader information followed by the contents of the bitmap. the three fields that we have to set in the bitmapinfoheader are the bftype which should always be "bm", the bfsize which is the size of the bitmap including the infoheader and the bfoffbits which is the offset to the bitmap bits from the start of the file.

If you have a device-dependent bitmap to begin with, you have to first create a dib from it. creating a dib from a ddb has already been covered in another section.

// writedib          - writes a dib to file
// returns          - true on success
// szfile          - name of file to write to
// hdib               - handle of the dib
bool writedib( lptstr szfile, handle hdib)
{
     bitmapfileheader     hdr;
     lpbitmapinfoheader     lpbi;

     if (!hdib)
          return false;  // invalid dib handle!!

     cfile file;
     if( !file.open( szfile, cfile::modewrite|cfile::modecreate) )
          return false;  // couldn't open the file

     lpbi = (lpbitmapinfoheader)hdib;

     int ncolors = 1 << lpbi->bibitcount;

     // fill in the fields of the file header
     hdr.bftype = ((word) ('m' << 8) | 'b'); // is always "bm"
        hdr.bfsize="globalsize" (hdib) + sizeof( hdr );
        hdr.bfreserved1="0;"
        hdr.bfreserved2="0;"
        hdr.bfoffbits="(dword)" (sizeof( hdr ) +
               lpbi->bisize + ncolors * sizeof(rgbquad));

     // write the file header
     file.write( &hdr, sizeof(hdr) );

     // write the dib header and the bits
     file.write( lpbi, globalsize(hdib) );

     return true;
}

I don't know how much C you understand, but . . .  this should give you a basic template of what needs to be in the file:  the header record, and the dib itself.  You should be able to create the file as a binary sequential file and write the header to it directly.  I think you'll have to convert the DIB handle to a working storage variable that's defined as an ADDRESS (IIRC, you can see the documentation on C$MALLOC for example of how to work with stuff like this) and work from that to extract the size of the DIB and then write it out.

I trust you have a subscription to the MSDN library?  That provides all the stuff you need to look at the layout of the DIB and BMP file.  If not, check MSDN.microsoft.com.  I find the MSDN stuff invaluable in working with AcuCOBOL and ActiveX controls/Win32 API.

Also, if you have a licensed copy of VB6.0, you may wish to create your own ActiveX control to do the save.  Probably take about 10 statements, if that (see SAVEPICTURE VB function documentation).  Of course you then have to register your control on the target machine(s) etc.

Another option is to buy one of the (expensive) graphics libraries that includes both TWAIN and BMP file saving functions.

Glenn
0
 

Expert Comment

by:quirkyquirky
Comment Utility
0
 

Expert Comment

by:ComTech
Comment Utility
This person has been suspended for multiple violations of the Member Agreement, and will reject the proposed answer, and return your question to the Active Questions List.  The Moderator Group is deleting all 388 locked questions.

These were posted by three persons:

quirkyquirky
EliteKiller
liloXwin
 
Thank you,
ComTech
CS Admin @ EE
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

To Enable Full Function of the Microsoft Office Keyboard (RT9450) in Vista 64 and Windows 7 These instructions worked for me using IntelliType v 6.1, but later versions of IntelliType might also work.  These suggestions work on Vista 64 bit, but …
I recently purchased an HP EliteBook 2540p notebook/laptop. It has two video ports on it – VGA and DisplayPort. HP offers an optional docking station for the 2540p that also has both a VGA port and a DisplayPort. There are numerous online reports do…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now