issue with buffer overflow?
Moderator: Alex
-
- Posts: 1
- Joined: Fri Dec 04, 2009 2:04 am
issue with buffer overflow?
I wrote a vb6 application that is using the activex control (vstwain.dll 5.1) to communicate with a canon powershot s3is thru the inphoto twain-compatible camera control from Mars Systems. I set the transfermode = memory(1) and when the image size is small all is well. But when I change the image size to medium or large My program crashes with a buffer issue. My program dies before reaching the VSTwain_PostScan subroutine. Any ideas how I can use higher resolution images in memory transfermode without the vstwain.dll *?
Re: issue with buffer overflow?
Hello,
If you have a problem with the scanner or other TWAIN device we recommend trying the following things:
If you have a problem with the scanner or other TWAIN device we recommend trying the following things:
- Get the latest version of the scanner's drivers from the *'s web site and re-install them.
- Make sure you have the latest version of VintaSoftTwain ActiveX.
- If you still have a problem, please generate a log-file of scanner's work and send it to us.
- Set the IsLoggingEnabled property to True before the StartDevice method.
- Set the path to log-file with the LogFilePath property if path "c:\vstwain.log" is not accessible by your application.
- Run your application.
- Send us a log-file and detailed description of the problem.
Re: issue with buffer overflow?
Hi guys,
I'm not sure my problem concerns to buffer but it's still about memory, so I decided to post it here.
We need to scan hundreds of pages in one session (the documents are recieved at one time and they have to be saved together), it's highly wishful to store them in one file, but (1) ADF only allows to set ~40 pages, but we found a solution by adding each next portion of pages when the previous one ends, (2) when the solution was found we faced with the "Error at allocation memory", which says about impossibility to save the pages we scanned.
As per my estimations, the TIFF file size must be about 350Mb (about 90 pages). TIFF file with 20 pages lasts for 80Mb and can easily be stored.
There the following questions to the development team since it seems that documentation does not explain it:
1. can we change the memory limit which does not allow to get such a big file from the scanner and/or to store such a file to a server (via http)?
2. if the answer is "no", what is the limit (if Mb's) for TIFF files which should be send via http?
Thanking you in advance.
Best regards,
Maxim
I'm not sure my problem concerns to buffer but it's still about memory, so I decided to post it here.
We need to scan hundreds of pages in one session (the documents are recieved at one time and they have to be saved together), it's highly wishful to store them in one file, but (1) ADF only allows to set ~40 pages, but we found a solution by adding each next portion of pages when the previous one ends, (2) when the solution was found we faced with the "Error at allocation memory", which says about impossibility to save the pages we scanned.
![Smile :-)](./images/smilies/icon_e_smile.gif)
There the following questions to the development team since it seems that documentation does not explain it:
1. can we change the memory limit which does not allow to get such a big file from the scanner and/or to store such a file to a server (via http)?
2. if the answer is "no", what is the limit (if Mb's) for TIFF files which should be send via http?
Thanking you in advance.
Best regards,
Maxim
Re: issue with buffer overflow?
Hello Maxim,
You can go by this way:
You can go by this way:
- Set the value of MaxImages property to 1, i.e. store only one image in the internal image buffer
- Add each acquired image to TIFF file in the handler of the PostScan event (Flag != 0)
- Upload TIFF file from the disk to the server using the SetHttpFileFromDisk method when this is necessary
Re: issue with buffer overflow?
Thanks Alexander.
Does not it mean we will get as much stored files as much pages are scanned?
Does not it mean we will get as much stored files as much pages are scanned?
Re: issue with buffer overflow?
You can set value of the TiffMultiPage property to True and all acquired images will be saved into one TIFF file. Please read the documentation.
VintaSoftTwain ActiveX has documentation in CHM format (VSTwain.chm file). You can find this file in /Documentation folder of the product installation.
Best regards, Alexander
VintaSoftTwain ActiveX has documentation in CHM format (VSTwain.chm file). You can find this file in /Documentation folder of the product installation.
Best regards, Alexander
Re: issue with buffer overflow?
Hi Alexander.
Our issue is not a unread documentation, we read it with attention but our basic knowledge of scanners and scanning process are not so deep, for instance the documentation does not explain what the internal buffer concerns to. Now I do understand that it stands for the memory buffer embedded into a scanner, and it made ActiveX API more clear to me, but common picture of the scanning process is not still quite clear. For instance, I still don't fully understand why everything goes successfully without PostScan event handling in one case (when ~20 pages are scanned in color 24bpp mode), and why it leads to "Error at allocating memory" when the number of pages grows. I beleive some descriptive sequence diagrams would help to avoid many questions.
Also I assume that it's just enough to use TransferMode property by setting it to File(2) value in order to store all images directly to a local file which then can be transfered via http.
Next week will try both - your suggestion and my assumption.
Thank you!
Our issue is not a unread documentation, we read it with attention but our basic knowledge of scanners and scanning process are not so deep, for instance the documentation does not explain what the internal buffer concerns to. Now I do understand that it stands for the memory buffer embedded into a scanner, and it made ActiveX API more clear to me, but common picture of the scanning process is not still quite clear. For instance, I still don't fully understand why everything goes successfully without PostScan event handling in one case (when ~20 pages are scanned in color 24bpp mode), and why it leads to "Error at allocating memory" when the number of pages grows. I beleive some descriptive sequence diagrams would help to avoid many questions.
Also I assume that it's just enough to use TransferMode property by setting it to File(2) value in order to store all images directly to a local file which then can be transfered via http.
Next week will try both - your suggestion and my assumption.
Thank you!
Re: issue with buffer overflow?
Here is information about the internal images buffer:
Best regards, Alexander
- Internal images buffer is used for storing images acquired from scanner when Native or Memory transfer mode is used.
- Internal images buffer is stored in memory of computer.
- Each Image is stored in non-compressed mode.
- Size of memory necessary for each Image can be calculated as follows: MEM_SIZE = IMAGE_WIDTH * IMAGE_HEIGHT * (BITS_PER_PIXEL / 8)
Best regards, Alexander
Re: issue with buffer overflow?
Hi all,
As I wrote before in the thread we tried storing scanned files into a multiple page TIFF, but failed with storing the TIFF file to server via SaveImageToHttp since the outcome file was too big for the transmission to server. We have implemented the following solution (kindly recommended by Alex):
- each scanned page is stored to the server as JPEG file,
- after all necessary pages are stored, we compile them into one PDF file using Apache FOP XSL formatter.
Of course this only helps when you need to get multipage document and does not solve other issues, but another advantage is that size of PDF file is significantly less than size of TIFF with same scanned pages - from 2 to 4 times (as of now we can observe).
By the way, we also found one little trick of the ActiveX - it seems that it breaks process(es) initiated by SaveImageToHttp when firing PostScan event since file sent to server is not saved. We found that delaying of StopDevice call in the PostScan event handler helps, here is a solution for JS:
As for the period (3000 ms = 3 sec), I believe it can depend on the file size and connection speed, but it work for us. Hope this can be helpful for others.
Best regards,
Maxim
P.S. I suggest to the development team to provide event processing schemes to the World since this can significantly help your customers in understanding of the ActiveX behaviour. For instance, the short-spoken phrase about PostScan event - "Fired after a scan or transfer ends.", does not let to understand that the event interrupts saving process(es) initiated by Save* functions.
As I wrote before in the thread we tried storing scanned files into a multiple page TIFF, but failed with storing the TIFF file to server via SaveImageToHttp since the outcome file was too big for the transmission to server. We have implemented the following solution (kindly recommended by Alex):
- each scanned page is stored to the server as JPEG file,
- after all necessary pages are stored, we compile them into one PDF file using Apache FOP XSL formatter.
Of course this only helps when you need to get multipage document and does not solve other issues, but another advantage is that size of PDF file is significantly less than size of TIFF with same scanned pages - from 2 to 4 times (as of now we can observe).
By the way, we also found one little trick of the ActiveX - it seems that it breaks process(es) initiated by SaveImageToHttp when firing PostScan event since file sent to server is not saved. We found that delaying of StopDevice call in the PostScan event handler helps, here is a solution for JS:
Code: Select all
window.setTimeout('VSTwain1.StopDevice()',3000);
Best regards,
Maxim
P.S. I suggest to the development team to provide event processing schemes to the World since this can significantly help your customers in understanding of the ActiveX behaviour. For instance, the short-spoken phrase about PostScan event - "Fired after a scan or transfer ends.", does not let to understand that the event interrupts saving process(es) initiated by Save* functions.