Read
Reads the pixel image data from a FITS file containing a single image.
Syntax
void* Read();
Parameters
None
Returns
void * - Pointer to the pixel image data. In most cases this pointer should be cast as an unsigned short *. The pointer should not be freed by the user; the class will handle that task.
Required Headers
CFitsFile.h
Namespace
arc
Throws
std::runtime_error
Remarks
None
Example
        // This code prints out the pixel image data from
        // a 16-bit FITS file. The image dimensions are read
        // from the header.

        #include <iostream>
        #include "CFitsFile.h"

        using namespace std;
        using namespace arc;

        int main()
        {
            long naxes[ CFitsFile::NAXES_SIZE ] = { 0, 0, 0 };

            try {
                CFitsFile cFits( "Image.fit" );

                unsigned short *pBuf = ( unsigned short * )cFits.Read();

                if ( pBuf == NULL )
                {
                    cerr << "Error: NULL image buffer!" << endl;
                    exit( 1 );
                }

                cFits.GetParameters( naxes );

                for ( int r=0; r<naxes[ CFitsFile::NAXES_ROW ]; r++ )
                {
                    for ( int c=0; c<naxes[ CFitsFile::NAXES_COL ]; c++ )
                    {
                        cout << "pix[ " << ( c + r * naxes[ CFitsFile::NAXES_COL ] )
                             << " ]: " << pBuf[ c + r * naxes[ CFitsFile::NAXES_COL ] ]
                             << endl;
                    }
                }
            }
            catch ( std::exception &e )
            {
                cerr << "Exception Occurred: " << e.what() << endl;
            }
        }

© Astronomical Research Cameras, Inc.