From dd45bba6ae46ee768764b02a45450035bd4b9020 Mon Sep 17 00:00:00 2001 From: Yann Le Poul Date: Tue, 9 Oct 2018 22:25:42 +0200 Subject: [PATCH] BUG: make sure the palette is empty when m_IsReadAsScalarPlusPalette is false Change-Id: Ie12910c8ebdd70f47afff12fdfacca08134a8856 --- Modules/IO/PNG/src/itkPNGImageIO.cxx | 5 +++++ Modules/IO/TIFF/src/itkTIFFImageIO.cxx | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Modules/IO/PNG/src/itkPNGImageIO.cxx b/Modules/IO/PNG/src/itkPNGImageIO.cxx index d80f3224557..5d9b2a0c114 100644 --- a/Modules/IO/PNG/src/itkPNGImageIO.cxx +++ b/Modules/IO/PNG/src/itkPNGImageIO.cxx @@ -429,6 +429,11 @@ void PNGImageIO::ReadImageInformation() } } + if( !m_IsReadAsScalarPlusPalette ) + { + // make sure not palette is left + m_ColorPalette.resize(0); + } // minimum of a byte per pixel if ( colorType == PNG_COLOR_TYPE_GRAY && bitDepth < 8 ) diff --git a/Modules/IO/TIFF/src/itkTIFFImageIO.cxx b/Modules/IO/TIFF/src/itkTIFFImageIO.cxx index 1dcc125fe2d..e1176650192 100644 --- a/Modules/IO/TIFF/src/itkTIFFImageIO.cxx +++ b/Modules/IO/TIFF/src/itkTIFFImageIO.cxx @@ -454,6 +454,11 @@ void TIFFImageIO::ReadImageInformation() } } } + if( !m_IsReadAsScalarPlusPalette ) + { + // make sure the palette is empty + m_ColorPalette.resize(0); + } if ( !m_InternalImage->CanRead() ) @@ -960,9 +965,14 @@ void TIFFImageIO::ReadTIFFTags() this->InitializeColors(); if ( m_TotalColors > -1 ) - {// if a palette have been found + {// if a palette have been found store it in m_ColorPalette PopulateColorPalette(); } + else + { + // otherwise make sure that the stored palette is empty in the case it was already set + m_ColorPalette.resize(0); + } for (int i = 0; i < tagCount; ++i) {