1 Commits

Author SHA1 Message Date
nou 467af80cb3 Fix reading ICCprofile 2023-06-05 12:21:27 +02:00
2 changed files with 19 additions and 15 deletions
+3 -1
View File
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.14)
project(libXISF VERSION 0.2.6 LANGUAGES CXX C
project(libXISF VERSION 0.2.7 LANGUAGES CXX C
HOMEPAGE_URL https://gitea.nouspiro.space/nou/libXISF
DESCRIPTION "LibXISF is C++ library that can read and write XISF files produced by PixInsight.")
@@ -92,6 +92,8 @@ else(USE_BUNDLED_LIBS)
list(APPEND PC_LIBS_REQUIRE lz4 pugixml zlib)
endif(USE_BUNDLED_LIBS)
target_link_libraries(XISF PUBLIC zstd)
set_target_properties(XISF PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
if(BUILD_SHARED_LIBS)
+15 -13
View File
@@ -541,6 +541,7 @@ private:
FITSKeyword parseFITSKeyword(const pugi::xml_node &node);
ColorFilterArray parseCFA(const pugi::xml_node &node);
Image parseImage(const pugi::xml_node &node);
void readAttachment(DataBlock &dataBlock);
std::unique_ptr<std::istream> _io;
std::unique_ptr<StreamBuffer> _buffer;
@@ -595,10 +596,7 @@ const Image& XISFReaderPrivate::getImage(uint32_t n, bool readPixels)
Image &img = _images[n];
if(img._dataBlock.attachmentPos && readPixels)
{
_io->seekg(img._dataBlock.attachmentPos);
ByteArray data(img._dataBlock.attachmentSize);
_io->read(data.data(), data.size());
img._dataBlock.decompress(data);
readAttachment(img._dataBlock);
}
return img;
}
@@ -734,17 +732,10 @@ Property XISFReaderPrivate::parseProperty(const pugi::xml_node &node)
{
DataBlock dataBlock = parseDataBlock(node);
if(dataBlock.attachmentPos)
{
data.resize(dataBlock.attachmentSize);
_io->seekg(dataBlock.attachmentPos);
_io->read(data.data(), dataBlock.attachmentSize);
dataBlock.decompress(data);
}
else
{
readAttachment(dataBlock);
data = dataBlock.data;
}
}
deserializeVariant(node, property.value, data);
@@ -812,6 +803,9 @@ Image XISFReaderPrivate::parseImage(const pugi::xml_node &node)
if(node.child("ICCProfile"))
{
DataBlock icc = parseDataBlock(node.child("ICCProfile"));
if(icc.attachmentPos)
readAttachment(icc);
image._iccProfile = icc.data;
}
@@ -821,6 +815,14 @@ Image XISFReaderPrivate::parseImage(const pugi::xml_node &node)
return image;
}
void XISFReaderPrivate::readAttachment(DataBlock &dataBlock)
{
ByteArray data(dataBlock.attachmentSize);
_io->seekg(dataBlock.attachmentPos);
_io->read(data.data(), dataBlock.attachmentSize);
dataBlock.decompress(data);
}
class XISFWriterPrivate
{
public: