This project has moved. For the latest updates, please go here.

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.

private void _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 support
            this.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 is object[]) {
                        foreach(var _value in _item.Value as object[]) {
                            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));
    }
}

Last edited Nov 26, 2016 at 8:17 PM by SARAFF, version 5