Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Controlling Scanner

Posted on 2002-06-13
9
Medium Priority
?
524 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 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 400 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
It started not too long ago. It was at first annoying. My keystrokes seemed to be randomly generated, not the ones I typed on the keyboard. For some reason this only happened in certain applications (especially browsers such as IE11, Firefox and Chr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

885 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