Solved

Controlling Scanner

Posted on 2002-06-13
9
515 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 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