From 6cfef0bc2e3ab5ba9c4665f8d985d79089daae27 Mon Sep 17 00:00:00 2001 From: malaterre Date: Wed, 3 Oct 2007 09:35:27 +0000 Subject: [PATCH] BUG: ooops this is a 16bits palette --- src/gdcmPixelReadConvert.cxx | 45 ++++++++++++++++++------------------ src/gdcmSegmentedPalette.h | 6 ++--- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index 686f007f..a2362820 100644 --- a/src/gdcmPixelReadConvert.cxx +++ b/src/gdcmPixelReadConvert.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelReadConvert.cxx,v $ Language: C++ - Date: $Date: 2007/10/03 09:31:08 $ - Version: $Revision: 1.124 $ + Date: $Date: 2007/10/03 09:35:27 $ + Version: $Revision: 1.125 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -199,27 +199,28 @@ void PixelReadConvert::GrabInformationsFromFile( File *file, LutRedDescriptor = file->GetEntryString( 0x0028, 0x1101 ); LutGreenDescriptor = file->GetEntryString( 0x0028, 0x1102 ); LutBlueDescriptor = file->GetEntryString( 0x0028, 0x1103 ); - if( file->GetDocEntry(0x0028,0x1221) ) // bla... + // Is it a Segmented Palette ? Check if we find the red one: + if( file->GetDocEntry(0x0028,0x1221) ) // no need to check for blue & green { - GDCM_NAME_SPACE::TagKey DCM_RedPaletteColorLookupTableDescriptor (0x0028, 0x1101); - GDCM_NAME_SPACE::TagKey DCM_GreenPaletteColorLookupTableDescriptor (0x0028, 0x1102); - GDCM_NAME_SPACE::TagKey DCM_BluePaletteColorLookupTableDescriptor (0x0028, 0x1103); - - GDCM_NAME_SPACE::TagKey DCM_SegmentedRedPaletteColorLookupTableData (0x0028, 0x1221); - GDCM_NAME_SPACE::TagKey DCM_SegmentedGreenPaletteColorLookupTableData (0x0028, 0x1222); - GDCM_NAME_SPACE::TagKey DCM_SegmentedBluePaletteColorLookupTableData (0x0028, 0x1223); - - - LutRedData = new uint8_t[65535]; - LutGreenData = new uint8_t[65535]; - LutBlueData = new uint8_t[65535]; - // TODO need to check file is indeed PALETTE COLOR: - ReadPaletteInto(file, DCM_RedPaletteColorLookupTableDescriptor, - DCM_SegmentedRedPaletteColorLookupTableData,LutRedData); - ReadPaletteInto(file, DCM_GreenPaletteColorLookupTableDescriptor, - DCM_SegmentedGreenPaletteColorLookupTableData,LutGreenData); - ReadPaletteInto(file, DCM_BluePaletteColorLookupTableDescriptor, - DCM_SegmentedBluePaletteColorLookupTableData,LutBlueData); + GDCM_NAME_SPACE::TagKey DCM_RedPaletteColorLookupTableDescriptor (0x0028, 0x1101); + GDCM_NAME_SPACE::TagKey DCM_GreenPaletteColorLookupTableDescriptor (0x0028, 0x1102); + GDCM_NAME_SPACE::TagKey DCM_BluePaletteColorLookupTableDescriptor (0x0028, 0x1103); + + GDCM_NAME_SPACE::TagKey DCM_SegmentedRedPaletteColorLookupTableData (0x0028, 0x1221); + GDCM_NAME_SPACE::TagKey DCM_SegmentedGreenPaletteColorLookupTableData (0x0028, 0x1222); + GDCM_NAME_SPACE::TagKey DCM_SegmentedBluePaletteColorLookupTableData (0x0028, 0x1223); + + + LutRedData = new uint8_t[65535*2]; // FIXME: leak + LutGreenData = new uint8_t[65535*2]; + LutBlueData = new uint8_t[65535*2]; + // TODO need to check file is indeed PALETTE COLOR: + ReadPaletteInto(file, DCM_RedPaletteColorLookupTableDescriptor, + DCM_SegmentedRedPaletteColorLookupTableData,LutRedData); + ReadPaletteInto(file, DCM_GreenPaletteColorLookupTableDescriptor, + DCM_SegmentedGreenPaletteColorLookupTableData,LutGreenData); + ReadPaletteInto(file, DCM_BluePaletteColorLookupTableDescriptor, + DCM_SegmentedBluePaletteColorLookupTableData,LutBlueData); } else diff --git a/src/gdcmSegmentedPalette.h b/src/gdcmSegmentedPalette.h index 550d1ad3..fff7bfae 100644 --- a/src/gdcmSegmentedPalette.h +++ b/src/gdcmSegmentedPalette.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSegmentedPalette.h,v $ Language: C++ - Date: $Date: 2007/10/03 09:31:16 $ - Version: $Revision: 1.2 $ + Date: $Date: 2007/10/03 09:35:27 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -216,7 +216,7 @@ namespace { std::vector palette; palette.reserve(num_entries); ExpandPalette(segment_values, length, palette); - memcpy(lut, &palette[0], palette.size() ); + memcpy(lut, &palette[0], palette.size()*2 ); // std::copy(palette.begin(), palette.end(), // std::ostream_iterator(std::cout, "\n")); -- 2.45.1