CCfits  2.4
Reading an Image

Image reading calls are made very simple: the FITS object is created with the readDataFlag set to true, and reading is done on construction. The following call


PHDU::read(std::valarray<S>& image).

This copies the entire image from the FITS object into the std::valarray object contents, sizing it as necessary. PHDU::read() and ExtHDU::read() [for image extensions] take a range of arguments that support (a) reading the entire image - as in this example; (b) sections of an image starting from a given pixel; (c) rectangular subsets. See the class references for PHDU and ExtHDU for details.

 int readImage()
        std::auto_ptr<FITS> pInfile(new FITS("",Read,true));
        PHDU& image = pInfile->pHDU(); 
        std::valarray<unsigned long>  contents;
        // read all user-specifed, coordinate, and checksum keys in the image
        // this doesn't print the data, just header info.
        std::cout << image << std::endl;
        long ax1(image.axis(0));
        long ax2(image.axis(1));
        for (long j = 0; j < ax2; j+=10)
                std::ostream_iterator<short> c(std::cout,"\t");
                std::cout << '\n';       
        std::cout << std::endl;
        return 0;