From 3141092456ade6f1332bf55fb9aa24313a7617a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Poizl?= Date: Thu, 9 Feb 2023 21:27:59 +0100 Subject: [PATCH] Add readPixel param to getImage() --- CMakeLists.txt | 2 +- libxisf.cpp | 8 ++++---- libxisf.h | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d874ce0..df47125 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.14) -project(libXISF VERSION 0.1.1 LANGUAGES CXX C) +project(libXISF VERSION 0.1.2 LANGUAGES CXX C) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) diff --git a/libxisf.cpp b/libxisf.cpp index 18c0fee..c41de12 100644 --- a/libxisf.cpp +++ b/libxisf.cpp @@ -404,12 +404,12 @@ bool Image::addFITSKeywordAsProperty(const QString &name, const QVariant &value) void *Image::imageData() { - return _dataBlock.data.data(); + return _dataBlock.data.isNull() ? nullptr : _dataBlock.data.data(); } const void *Image::imageData() const { - return _dataBlock.data.data(); + return _dataBlock.data.isNull() ? nullptr : _dataBlock.data.data(); } size_t Image::imageDataSize() const @@ -591,13 +591,13 @@ int XISFReader::imagesCount() const return _images.size(); } -const Image& XISFReader::getImage(uint32_t n) +const Image& XISFReader::getImage(uint32_t n, bool readPixels) { if(n >= _images.size()) throw Error("Out of bounds"); Image &img = _images[n]; - if(img._dataBlock.attachmentPos) + if(img._dataBlock.attachmentPos && readPixels) { _io->seek(img._dataBlock.attachmentPos); img._dataBlock.decompress(_io->read(img._dataBlock.attachmentSize)); diff --git a/libxisf.h b/libxisf.h index df7b3e5..06848fc 100644 --- a/libxisf.h +++ b/libxisf.h @@ -227,7 +227,11 @@ public: void close(); /** Return number of images inside file */ int imagesCount() const; - const Image& getImage(uint32_t n); + /** Return reference to Image + * @param n index of image + * @param readPixel when false it will read pixel data from file and imageData() + * will return nullptr */ + const Image& getImage(uint32_t n, bool readPixels = true); private: void readXISFHeader(); void readSignature();