Write3D
Add an image to the end of a FITS data cube.
Syntax
void Write3D( data );
Parameters
void* data
Pointer to the pixel image data.
Returns
None
Required Headers
CFitsFile.h
Namespace
arc
Throws
std::runtime_error
Remarks
None
Example
        // This code demonstrates how to add a 1024x1200
        // pixel image to a FITS data cube. The image is
        // a gradient.

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

        using namespace std;
        using namespace arc;

        int main()
        {
            unsigned short *pBuf = NULL;
            unsigned short val = 0;

            try {
                //
                // Create a new FITS data cube
                //
                CFitsFile cFits( "Image.fit", 1024, 1200, CFitsFile::BPP16, true );

                //
                // Create new image data
                //
                pBuf = new unsigned short[ 1024 * 1200 ];

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

                //
                // Fill the new buffer with a gradient image
                //
                for ( int r=0; r<1024; r++ )
                {
                    for ( int c=0; c<1200; c++ )
                    {
                        pBuf[ c + r * 1200 ] = val;
                    }

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

                //
                // Write the image data
                //
                cFits.Write3D( pBuf );

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

© Astronomical Research Cameras, Inc.