Program: gdcm
Module: $RCSfile: gdcmPixelReadConvert.cxx,v $
Language: C++
- Date: $Date: 2005/02/05 01:37:09 $
- Version: $Revision: 1.49 $
+ Date: $Date: 2005/02/23 09:54:59 $
+ Version: $Revision: 1.53 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
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:
//// Third stage: twigle the bytes and bits.
ConvertReorderEndianity();
ConvertReArrangeBits();
+ ConvertFixGreyLevels();
ConvertHandleColor();
return true;
}
}
+/**
+ * \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<RawSize; i++)
+ {
+ *deb = 255 - *deb;
+ deb++;
+ }
+ return;
+ }
+
+ if ( BitsAllocated == 16 )
+ {
+ uint16_t mask =1;
+ for (j=0; j<BitsStored-1; j++)
+ {
+ mask = (mask << 1) +1; // will be fff when BitsStored=12
+ }
+
+ uint16_t *deb = (uint16_t *)Raw;
+ for (i=0; i<RawSize/2; i++)
+ {
+ *deb = mask - *deb;
+ deb++;
+ }
+ return;
+ }
+ }
+ else
+ {
+ if ( BitsAllocated == 8 )
+ {
+ uint8_t smask8 = 255;
+ uint8_t *deb = (uint8_t *)Raw;
+ for (i=0; i<RawSize; i++)
+ {
+ *deb = smask8 - *deb;
+ deb++;
+ }
+ return;
+ }
+ if ( BitsAllocated == 16 )
+ {
+ uint16_t smask16 = 65535;
+ uint16_t *deb = (uint16_t *)Raw;
+ for (i=0; i<RawSize/2; i++)
+ {
+ *deb = smask16 - *deb;
+ deb++;
+ }
+ return;
+ }
+ }
+}
+
/**
* \brief Re-arrange the bits within the bytes.
- * @return Boolean
+ * @return Boolean always true
*/
bool PixelReadConvert::ConvertReArrangeBits() throw ( FormatError )
{