X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmPixelReadConvert.cxx;h=2970f1f01e73b5b3a57493f00659e6a54f808660;hb=5dc31f3b74c8da7f8c59caa4d2255d1d0e7a03d2;hp=78075ab2a940da5e70cb2ff968c48d7e95d2e5b9;hpb=95e43356511d138225d8f718f632b3e7a8fcc106;p=gdcm.git diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index 78075ab2..2970f1f0 100644 --- a/src/gdcmPixelReadConvert.cxx +++ b/src/gdcmPixelReadConvert.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelReadConvert.cxx,v $ Language: C++ - Date: $Date: 2005/02/05 01:37:09 $ - Version: $Revision: 1.49 $ + Date: $Date: 2005/03/31 09:46:51 $ + Version: $Revision: 1.54 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -123,13 +123,15 @@ void PixelReadConvert::GrabInformationsFromFile( File *file ) PixelOffset = file->GetPixelOffset(); PixelDataLength = file->GetPixelAreaLength(); - RLEInfo = file->GetRLEInfo(); - JPEGInfo = file->GetJPEGInfo(); + RLEInfo = file->GetRLEInfo(); + JPEGInfo = file->GetJPEGInfo(); + + IsMonochrome = file->IsMonochrome(); + IsMonochrome1 = file->IsMonochrome1(); + IsPaletteColor = file->IsPaletteColor(); + IsYBRFull = file->IsYBRFull(); PlanarConfiguration = file->GetPlanarConfiguration(); - IsMonochrome = file->IsMonochrome(); - IsPaletteColor = file->IsPaletteColor(); - IsYBRFull = file->IsYBRFull(); ///////////////////////////////////////////////////////////////// // LUT section: @@ -262,6 +264,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) //// Third stage: twigle the bytes and bits. ConvertReorderEndianity(); ConvertReArrangeBits(); + ConvertFixGreyLevels(); ConvertHandleColor(); return true; @@ -641,9 +644,78 @@ void PixelReadConvert::ConvertReorderEndianity() } } +/** + * \brief Deal with Grey levels i.e. re-arange them + * to have low values = dark, high values = bright + */ +void PixelReadConvert::ConvertFixGreyLevels() +{ + if (!IsMonochrome1) + return; + + uint32_t i; // to please M$VC6 + int16_t j; + + if (!PixelSign) + { + if ( BitsAllocated == 8 ) + { + uint8_t *deb = (uint8_t *)Raw; + for (i=0; i 255.0) R = 255.0; - if (G > 255.0) G = 255.0; - if (B > 255.0) B = 255.0; + R = 38142 *(*a-16) + 52298 *(*c -128); + G = 38142 *(*a-16) - 26640 *(*c -128) - 12845 *(*b -128); + B = 38142 *(*a-16) + 66093 *(*b -128); + + R = (R+16384)>>15; + G = (G+16384)>>15; + B = (B+16384)>>15; + + if (R < 0) R = 0; + if (G < 0) G = 0; + if (B < 0) B = 0; + if (R > 255) R = 255; + if (G > 255) G = 255; + if (B > 255) B = 255; *(localRaw++) = (uint8_t)R; *(localRaw++) = (uint8_t)G;