Solved

Controlling Scanner

Posted on 2002-06-13
9
513 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
ID: 7147211
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 7147216
0
 
LVL 1

Expert Comment

by:mitchg
ID: 7223332
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
New! My Passport Wireless Pro Wi-Fi Mobile Storage

Portable wireless storage to offload, edit, and stream anywhere.

High-capacity, wireless mobile storage designed to accompany professional photographers and videographers in the field to easily offload, edit and stream captured photos and high-definition videos.

 

Author Comment

by:marianpancik
ID: 7224972
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
ID: 7225492
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
ID: 7299438
0
 

Expert Comment

by:ComTech
ID: 7300727
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
pos for resturant 5 51
Windows 7 Computer - Ctrl C & Ctrl V not working 6 78
fm200 2 76
CAPS state utility needed. 5 79
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…
If you are having problems installing printer drivers, or if documents repeatedly get stuck in the print queue even after re-installing the printer drivers, then follow these steps to solve the problems. Please note that the steps are shown both for…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

911 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

22 Experts available now in Live!

Get 1:1 Help Now