Loading...

SaveAsByteArray: optimize ?

Support for GdTwain ActiveX and GdTwain Pro ActiveX/SDK.

SaveAsByteArray: optimize ?

Postby ctn » Thu Feb 05, 2009 12:22 pm

Hi

If I perform safe a image after scan (SaveAsByteArray) with 600dpi color and BMP/TIFF as byte array (in memory) it takes too long (more that 10 min.).
Is it somehow possible to optimize this process?

Thank you
Br,
Toan
ctn
 
Posts: 57
Joined: Thu Dec 04, 2008 6:20 pm

Re: SaveAsByteArray: optimize ?

Postby Loïc » Thu Feb 05, 2009 5:34 pm

it takes too long (more that 10 min.).


Hum... I am a bit surprised. Could you give me some of line of code ?

Best regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4441
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: SaveAsByteArray: optimize ?

Postby ctn » Fri Feb 06, 2009 10:52 am

Sorry, it takes more than 8min. After more than 8 minutes I got a communcation timeout (CommunicationException).

System information: WinXP, Intel Core(TM)2 Duo CPU 2.10 GHz, 3GB RAM
Please find below the code sample: Test with 600dpi, BMP format

Code: Select all
[b]   byte[] imageBytes = new byte[0];
   int nBytesRead = imageBytes.Length;[/b]

   // Save to byte array check
   DateTime start = DateTime.Now;
   _logger.logDebug("imageOrPreviewScan(): save to byte array timer start time --> {0}", start);

   [b]_gdTwain.SaveAsByteArray(ref imageBytes, ref nBytesRead, imageFormat.ToString(), 0);[/b]

   DateTime end = DateTime.Now;
   _logger.logDebug("imageOrPreviewScan(): save to byte array timer stop time --> {0}", end);
   _logger.logDebug("imageOrPreviewScan(): save to byte array time elapsed: {0}", end - start);

[b]   image = new byte[imageBytes.Length];
   imageBytes.CopyTo(image, 0);[/b]


Logs:
imageOrPreviewScan(): save to byte array timer start time --> 02/06/2009 09:37:51
imageOrPreviewScan(): save to byte array timer stop time --> 02/06/2009 09:46:01
imageOrPreviewScan(): save to byte array time elapsed: 00:08:09.3663700

Br, ctn
ctn
 
Posts: 57
Joined: Thu Dec 04, 2008 6:20 pm

Re: SaveAsByteArray: optimize ?

Postby ctn » Tue Feb 10, 2009 3:09 pm

Hi Loïc

Do you have any news about this issue?
Thanks
ctn
ctn
 
Posts: 57
Joined: Thu Dec 04, 2008 6:20 pm

Re: SaveAsByteArray: optimize ?

Postby Loïc » Tue Feb 10, 2009 5:52 pm

Hi,

Saving a 600 DPI image as bitmap format is not a good idea.
I suggest you to use a format using compression schemes such as TIFF or JPEG. Your saving time should be dramatically decreased.


Best regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4441
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: SaveAsByteArray: optimize ?

Postby ctn » Wed Feb 11, 2009 10:43 am

The Data compression of TIFF is not much better. Also after more than 8 minutes I got a communication timeout:

imageOrPreviewScan(): save to byte array timer start time --> 02/11/2009 09:26:52
imageOrPreviewScan(): save to byte array timer stop time --> 02/11/2009 09:35:05
imageOrPreviewScan(): save to byte array time elapsed: 00:08:13.5526205

But JPEG is faster (~10 seconds for 7534771 Bytes):
imageOrPreviewScan(): save to byte array timer start time --> 02/11/2009 09:39:07
imageOrPreviewScan(): save to byte array timer stop time --> 02/11/2009 09:39:18
imageOrPreviewScan(): save to byte array time elapsed: 00:00:10.5055973

Br, ctn
ctn
 
Posts: 57
Joined: Thu Dec 04, 2008 6:20 pm

Re: SaveAsByteArray: optimize ?

Postby Loïc » Thu Feb 12, 2009 7:30 pm

Hi,

For the tiff format you should select a compression scheme.

In all case I suggest you to use TIFF with CCITT4 compression for bitonal image and JPEG compression for color images.

With best regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4441
Joined: Tue Oct 17, 2006 10:48 pm
Location: France


Return to GdTwain [Pro] ActiveX

Who is online

Users browsing this forum: Google [Bot] and 1 guest