diff --git a/loadrunable.cpp b/loadrunable.cpp index b6192de..5372a10 100644 --- a/loadrunable.cpp +++ b/loadrunable.cpp @@ -274,6 +274,15 @@ bool loadFITS(const QString path, ImageInfoData &info, std::shared_ptr if(file) loadFITSHeader(file, info); + if(image) + { + for(auto fits : info.fitsHeader) + { + if(fits.key == "ROWORDER" && fits.value == "BOTTOM-UP") + image->flip(); + } + } + fits_close_file(file, &status); if(status) { diff --git a/rawimage.cpp b/rawimage.cpp index 3234319..744e0a2 100644 --- a/rawimage.cpp +++ b/rawimage.cpp @@ -658,6 +658,15 @@ std::pair RawImage::unitScale() const return {1.0f, 0.0f}; } +void RawImage::flip() +{ + std::unique_ptr tmp = std::move(m_pixels); + allocate(m_width, m_height, m_channels, m_type); + uint32_t rowSize = m_width * m_ch * typeSize(m_type); + for(uint32_t i=0; i RawImage::fromPlanar(const RawImage &img) { return RawImage::fromPlanar(img.data(), img.width(), img.height(), img.channels(), img.type()); diff --git a/rawimage.h b/rawimage.h index ef5b4fd..a133011 100644 --- a/rawimage.h +++ b/rawimage.h @@ -99,6 +99,7 @@ public: bool pixel(int x, int y, double &r, double &g, double &b) const; void resize(uint32_t w, uint32_t h); std::pair unitScale() const; + void flip(); static std::shared_ptr fromPlanar(const RawImage &img); static std::shared_ptr fromPlanar(const void *pixels, uint32_t w, uint32_t h, uint32_t ch, DataType type);