]> Creatis software - gdcm.git/commitdiff
BUG: ooops this is a 16bits palette
authormalaterre <malaterre>
Wed, 3 Oct 2007 09:35:27 +0000 (09:35 +0000)
committermalaterre <malaterre>
Wed, 3 Oct 2007 09:35:27 +0000 (09:35 +0000)
src/gdcmPixelReadConvert.cxx
src/gdcmSegmentedPalette.h

index 686f007ff260d4d0c2e4fb5f97a475b7048bfcf0..a236282066cf064baeb5ae379d7aaac880e542eb 100644 (file)
@@ -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
index 550d1ad369ac46f21342106430dfded8d604d92e..fff7bfaec7eb007a6eda56cb6cc7f80c55b6a84b 100644 (file)
@@ -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<uint16_t> 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<uint16_t>(std::cout, "\n"));