From c4f25c32edc02220fd13f341eb2bbef705fda266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Poizl?= Date: Sat, 28 Sep 2019 09:54:33 +0200 Subject: [PATCH] Fix loading FITS --- loadrunable.cpp | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/loadrunable.cpp b/loadrunable.cpp index bf75ca0..0c66efb 100644 --- a/loadrunable.cpp +++ b/loadrunable.cpp @@ -111,20 +111,19 @@ bool loadFITS(QString path, ImageInfoData &info, RawImageAbs **image, QImage *qi long naxes[2]; fits_get_img_param(file, 2, &imgtype, &naxis, naxes, &status); - if(naxis == 2 && status == 0) + if(naxis >= 2 && naxis <= 3 && status == 0) { std::vector bits8; std::vector bits16; std::vector bits32; - long fpixel[2] = {1,1}; + long fpixel[3] = {1,1,1}; size_t size = naxes[0]*naxes[1]; - uchar *data = nullptr; + size_t w = naxes[0]; + size_t h = naxes[1]; if(qimage) - { *qimage = QImage(naxes[0], naxes[1], QImage::Format_Grayscale8); - data = qimage->bits(); - } + info.append(StringPair(QObject::tr("Width"), QString::number(naxes[0]))); info.append(StringPair(QObject::tr("Height"), QString::number(naxes[1]))); @@ -134,10 +133,10 @@ bool loadFITS(QString path, ImageInfoData &info, RawImageAbs **image, QImage *qi bits8.resize(size); fits_read_pix(file, TBYTE, fpixel, size, NULL, &bits8[0], NULL, &status); if(status)break; - if(data) + if(qimage) { - for(size_t i=0; iscanLine(i), &bits8[i*w], w*sizeof(uint8_t)); } if(image)*image = new RawImage(naxes[0], naxes[1], bits8); break; @@ -145,10 +144,14 @@ bool loadFITS(QString path, ImageInfoData &info, RawImageAbs **image, QImage *qi bits16.resize(size); fits_read_pix(file, TUSHORT, fpixel, size, NULL, &bits16[0], NULL, &status); if(status)break; - if(data) + if(qimage) { - for(size_t i=0; i> 8; + for(size_t i=0; iscanLine(i); + for(size_t o=0;o> 8; + } } if(image)*image = new RawImage(naxes[0], naxes[1], bits16); break; @@ -156,10 +159,14 @@ bool loadFITS(QString path, ImageInfoData &info, RawImageAbs **image, QImage *qi bits32.resize(size); fits_read_pix(file, TUINT, fpixel, size, NULL, &bits32[0], NULL, &status); if(status)break; - if(data) + if(qimage) { - for(size_t i=0; i> 24; + for(size_t i=0; iscanLine(i); + for(size_t o=0;o> 24; + } } if(image)*image = new RawImage(naxes[0], naxes[1], bits32); break;