AForge.Imaging.Formats.PNMCodec.DecodeFrame C# (CSharp) Method

DecodeFrame() public method

Decode specified frame.
No image stream was opened previously. Stream does not contain frame with specified index. The stream contains invalid (broken) PNM image.
public DecodeFrame ( int frameIndex, ImageInfo &imageInfo ) : Bitmap
frameIndex int Image frame to decode.
imageInfo ImageInfo Receives information about decoded frame.
return System.Drawing.Bitmap
        public Bitmap DecodeFrame( int frameIndex, out ImageInfo imageInfo )
        {
            // check requested frame index
            if ( frameIndex != 0 )
            {
                throw new ArgumentOutOfRangeException( "Currently opened stream does not contain frame with specified index." );
            }

            // seek to the required frame
            stream.Seek( dataPosition, SeekOrigin.Begin );

            // read required frame
            Bitmap image = ReadImageFrame( stream, this.imageInfo );

            // provide also frame information
            imageInfo = (PNMImageInfo) this.imageInfo.Clone( );

            return image;
        }