// Copyright (C) 1999-2018 // Smithsonian Astrophysical Observatory, Cambridge, MA, USA // For conditions of distribution and use, see copyright notice in "copyright" #include #include #include using namespace std; #include #include "photo.h" FitsPhoto::FitsPhoto(Tcl_Interp* interp, const char* ph) { // reset valid_ = 0; if (*ph == '\0') { Tcl_AppendResult(interp, "bad image name ", NULL); return; } Tk_PhotoHandle photo = Tk_FindPhoto(interp, ph); if (!photo) { Tcl_AppendResult(interp, "bad image handle ", NULL); return; } Tk_PhotoImageBlock block; if (!Tk_PhotoGetImage(photo,&block)) { Tcl_AppendResult(interp, "bad image block ", NULL); return; } int width =0; int height =0; Tk_PhotoGetSize(photo, &width, &height); // new header head_ = new FitsHead(width, height, 1, 8); if (!head_->isValid()) return; size_t size = (size_t)width*height; unsigned char* dest = new unsigned char[size]; data_ = dest; dataSize_ = size; dataSkip_ = 0; unsigned char* src = block.pixelPtr; for (int jj=height-1; jj>=0; jj--) for (int ii=0; iiisValid()) return; size_t size = (size_t)width*height*depth; unsigned char* dest = new unsigned char[size]; data_ = dest; dataSize_ = size; dataSkip_ = 0; unsigned char* src = block.pixelPtr; for (int kk=0; kk=0; jj--) { for (int ii=0; iiprimary(); managePrimary_ = 0; head_ = prev->head(); manageHead_ = 0; FitsImageHDU* hdu = (FitsImageHDU*)head_->hdu(); data_ = (char*)prev->data() + hdu->imgbytes(); dataSize_ = 0; dataSkip_ = 0; ext_ = prev->ext(); inherit_ = head_->inherit(); byteswap_ = prev->byteswap(); endian_ = prev->endian(); valid_ = 1; return; }