This project has moved and is read-only. For the latest updates, please go here.

Out of range

May 10, 2014 at 12:24 PM
Hi Saraff,

I want to set the JPEG quality, used below code :
            if ((twain321.IsCapSupported(TwCap.JpegQuality) & TwQC.Set) != 0)
                twain321.SetCap(TwCap.JpegQuality, (int)-3);
but it will show out of range error...what's wrong ? In fact I want to use this to minimize the scanned image size. thx.
May 10, 2014 at 1:24 PM
Hello, xgc521.
Image
Marked as answer by SARAFF on 6/23/2014 at 12:25 PM
May 12, 2014 at 3:17 AM
Hi Saraff,

thanks for your answer, strange is if I set the color parameter as below,
                   twain321.Capabilities.PixelType.Set(TwPixelType.BW);
then I set
twain321.SetCap(TwCap.JpegQuality, -3);
the program will work well.

But if I set the color paramter as below:
twain321.Capabilities.PixelType.Set(TwPixelType.RGB);
then I set
twain321.SetCap(TwCap.JpegQuality, -3);
the program will alert 'out of range' error.
May 12, 2014 at 6:05 AM
Edited May 12, 2014 at 6:07 AM
Hello, xgc521.
Try update Saraff.Twain.NET source code from https://sarafftwain.codeplex.com/SourceControl/latest
and use follow:
if((this._twain32.IsCapSupported(TwCap.JpegQuality) & TwQC.Set) != 0) {
     this._twain32.SetCap(TwCap.JpegQuality, (short)-3);
}
May 12, 2014 at 8:22 AM
Hi Saraff,

Many thanks for quick response, I will try later this evening. I still has another question, for below code, it will show error about 'the reference object is null'
I also dubug to the details, the error occured at the first row , in the method 'IsCapSupported', what's wrong? thx.

if ((twain321.IsCapSupported(TwCap.ICAP_AUTODISCARDBLANKPAGES) & TwQC.Set) != 0)
                twain321.SetCap(TwCap.ICAP_AUTODISCARDBLANKPAGES, scanSettingEN.AutoDiscardBlank);
May 12, 2014 at 8:58 AM
Hello, xgc521.
Move this issue to the corresponding topic and add a stack trace.

xgc521 wrote:
Hi Saraff,

Many thanks for quick response, I will try later this evening. I still has another question, for below code, it will show error about 'the reference object is null'
I also dubug to the details, the error occured at the first row , in the method 'IsCapSupported', what's wrong? thx.

if ((twain321.IsCapSupported(TwCap.ICAP_AUTODISCARDBLANKPAGES) & TwQC.Set) != 0)
                twain321.SetCap(TwCap.ICAP_AUTODISCARDBLANKPAGES, scanSettingEN.AutoDiscardBlank);