WriteSubImage
Writes a sub-image to a FITS file.
Syntax
void WriteSubImage( llrow, llcol, urrow, urcol, data );
Parameters
long llrow
Lower left row pixel.
long llcol
Lower left column pixel.
long urrow
Upper right row pixel.
long urcol
Upper right column pixel.
void* data
Pointer to pixel image data.
Returns
None
Required Headers
CFitsFile.h
Namespace
arc
Throws
std::runtime_error
Remarks
None
Example
        // This code demonstrates how to write a 100x300
        // pixel sub-image at position ( 300, 100 ), 
        // ( 600, 200 ).
        //
        //               Primary Image
        //  +----------------------------------------+
        //  |             600                        |
        //  |<-------------------------->            |
        //  |         +----------------+ ^           |
        //  |         |   Sub-Image    | |           |
        //  |   300   |  ( 100x140 )   | |           |
        //  |<------->+----------------+ | 200       |
        //  |        ^                   |           |
        //  |        | 100               |           |
        //  |        V                   V           |
        //  +----------------------------------------+
        //
        #include <iostream>
        #include "CFitsFile.h"

        using namespace std;
        using namespace arc;

        int main()
        {
            long naxes[ CFitsFile::NAXES_SIZE ] = { 0, 0, 0 };
            unsigned short *pBuf = NULL;
            unsigned short val = 0;

            try {
                CFitsFile cFits( "Image.fit", 1024, 1200 );

                pBuf = new unsigned short[ 100 * 300 ];

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

                for ( int r=0; r<100; r++ )
                {
                    for ( int c=0; c<300; c++ )
                    {
                        pBuf[ c + r * 300 ] = val;
                    }

                    if ( val >= 65535 ) val = 0;
                    else val++;
                }

                cFits.WriteSubImage( 100, 300, 200, 600, pBuf );

                delete[] pBuf;
            }
            catch ( std::exception &e )
            {
                cerr << "Exception Occurred: " << e.what() << endl;
                if ( pBuf != NULL ) delete[] pBuf;
            }
        }

© Astronomical Research Cameras, Inc.