Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Controlling Scanner

Posted on 2002-06-13
9
Medium Priority
?
526 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
7 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
Enhanced Intelligibility Without Cable Clutter

Challenge: The ESA office in Brussels wanted a reliable audio conference system for video conferences. Their requirement - No participant must be left out from the conference and the audio quality must not be compromised.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
For years I have put up with a wireless mouse that consistently disappears or is non-responsive.  This is the story of how I discovered it wasn't really the mouse!
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month12 days, 6 hours left to enroll

564 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