Accord.Imaging.Formats.FITSCodec.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) FITS 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 >= this.imageInfo.TotalFrames)
            {
                throw new ArgumentOutOfRangeException("Currently opened stream does not contain frame with specified index.");
            }

            // seek to the required frame
            stream.Seek(dataPosition + frameIndex * this.imageInfo.Width * this.imageInfo.Height *
                Math.Abs(this.imageInfo.OriginalBitsPerPixl) / 8, SeekOrigin.Begin);

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

            // provide also frame information
            imageInfo = (FITSImageInfo)this.imageInfo.Clone();
            imageInfo.FrameIndex = frameIndex;

            return image;
        }