Quantcast
Channel: Saraff.Twain.NET
Viewing all articles
Browse latest Browse all 419

Updated Wiki: Image Information and Extended Image Information

$
0
0

Image Information and Extended Image Information

To retrieve image information and extended image information need to handle the XferDone event. This event is raised for each of the received image.
The following example shows how to do it.

privatevoid _twain32_XferDone(object sender,Twain32.XferDoneEventArgs e) {
    try {
        #region Image info

        this.textBox1.AppendText(string.Format("Image Info:{0}",Environment.NewLine));
        var _imageInfo=e.GetImageInfo();
        this.textBox1.AppendText(string.Format("YResolution={0}; XResolution={1}; PixelType={2}; SamplesPerPixel={3}; ImageWidth={4}; ImageLength={5};{6}",_imageInfo.YResolution,_imageInfo.XResolution,_imageInfo.PixelType,_imageInfo.SamplesPerPixel,_imageInfo.ImageWidth,_imageInfo.ImageLength,Environment.NewLine));

        #endregion#region Extended Image Info

        if((this._twain32.IsCapSupported(TwCap.ExtImageInfo)&TwQC.Get)!=0) { // if extended image info supportthis.textBox1.AppendText("Extended Image Info:");
            var _extImageInfo=e.GetExtImageInfo(new TwEI[] { TwEI.BarCodeCount,TwEI.BarCodeType,TwEI.BarCodeTextLength,TwEI.Camera,TwEI.Frame,TwEI.PixelFlavor,TwEI.DocumentNumber });

            #region Show info

            foreach(var _item in _extImageInfo) {
                this.textBox1.AppendText(string.Format("{0}{1} = ",Environment.NewLine,_item.InfoId));
                if(_item.IsSuccess) {
                    if(_item.Value isobject[]) {
                        foreach(var _value in _item.Value asobject[]) {
                            this.textBox1.AppendText(string.Format("{0}; ",_value));
                        }
                    } else {
                        this.textBox1.AppendText(string.Format("{0}; ",_item.Value));
                    }
                }
                if(_item.IsNotAvailable) {
                    this.textBox1.AppendText("NotAvailable");
                }
                if(_item.IsNotSupported) {
                    this.textBox1.AppendText("NotSupported");
                }
            }

        }

        #endregion#endregion
    } catch(Exception ex) {
        this.textBox1.AppendText(string.Format("{0}: {1}",ex.GetType().Name,ex.Message));
    }
}

Viewing all articles
Browse latest Browse all 419

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>