-// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.105 2003/10/31 10:38:34 jpr Exp $
+// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.108 2003/11/05 17:14:59 malaterre Exp $
#include "gdcmHeader.h"
/**
* \ingroup gdcmHeader
* \brief Retrieve the number of Samples Per Pixel
- * (1 : gray level, 3 : RGB)
+ * (1 : gray level, 3 : RGB -1 or 3 Planes-)
*
* @return The encountered number of Samples Per Pixel, 1 by default.
*/
* - 32U unsigned 32 bit,
* - 32S signed 32 bit,
* \warning 12 bit images appear as 16 bit.
+ * \ 24 bit images appear as 8 bit
* @return
*/
std::string gdcmHeader::GetPixelType(void) {
dbg.Verbose(0, "gdcmHeader::GetPixelType: unfound Bits Allocated");
BitsAlloc = std::string("16");
}
- if (BitsAlloc == "12")
+ if (BitsAlloc == "12") // It will be unpacked
BitsAlloc = std::string("16");
-
+ else if (BitsAlloc == "24") // (in order no to be messed up
+ BitsAlloc = std::string("8"); // by old RGB images)
+
std::string Signed;
Signed = GetElValByName("Pixel Representation");
if (Signed == GDCM_UNFOUND) {
if (Signed == "0")
Signed = std::string("U");
else
+
+std::cout << "GetPixelType : " << BitsAlloc + Signed << std::endl;
Signed = std::string("S");
return( BitsAlloc + Signed);
/**
* \ingroup gdcmHeader
* \brief tells us if LUT are used
+ * \warning Right now, Segmented xxx Palette Color Lookup Table Data
+ * \ are NOT considered as LUT, since nobody knows
+ *\ how to deal with them
* @return int acts as a Boolean
*/
int gdcmHeader::HasLUT(void) {
- // Just hope checking the presence of the LUT Descriptors is enough
+ // Check the presence of the LUT Descriptors
if (GetPubElValByNumber(0x0028,0x1101) == GDCM_UNFOUND)
return 0;
// LutDescriptorGreen
return 0;
// LutDescriptorBlue
if (GetPubElValByNumber(0x0028,0x1103) == GDCM_UNFOUND)
+ return 0;
+ // It is not enough
+ // we check also
+ if (GetPubElValByNumber(0x0028,0x1201) == GDCM_UNFOUND)
return 0;
+ if (GetPubElValByNumber(0x0028,0x1202) == GDCM_UNFOUND)
+ return 0;
+ if (GetPubElValByNumber(0x0028,0x1203) == GDCM_UNFOUND)
+ return 0;
return 1;
}
char *LUTRGBA = (char *)calloc(1024,1); // 256 * 4 (R, G, B, Alpha)
if (!LUTRGBA) {
return NULL;
- }
+ }
+ memset(LUTRGBA, 0, 1024);
// Bits Allocated
int nb;
std::string str_nb = GetPubElValByNumber(0x0028,0x0100);
// if it works, we shall have to check the 3 Palettes
// to see which byte is ==0 (first one, or second one)
// and fix the code
- // We give up the checking to avoid some overhead
+ // We give up the checking to avoid some overhead
+
char *a;
- a= LUTRGBA+debR;
- for(int i=0;i<lengthR;i++) {
+ int i;
+ a= LUTRGBA+0;
+ for(i=0;i<lengthR;i++) {
*a = lutR[i*mult+1];
a+=4;
}
- a= LUTRGBA+debG;
- for(int i=0;i<lengthG;i++) {
- *(a+1) = lutG[i*mult+1];
+ a= LUTRGBA+1;
+ for(i=0;i<lengthG;i++) {
+ *a = lutG[i*mult+1];
a+=4;
}
- a= LUTRGBA+debB;
- for(int i=0;i<lengthB;i++) {
- *(a+2) = lutB[i*mult+1];
+ a= LUTRGBA+2;
+ for(i=0;i<lengthB;i++) {
+ *a = lutB[i*mult+1];
a+=4;
}
- for(int i=0;i<255;i++) {
- *(a+3) = 1; // Alpha component
+ a= LUTRGBA+3;
+ for(i=0;i<256;i++) {
+ *a = 1; // Alpha component
a+=4;
}
-
-// WHY does it seg fault ?!?
-//free(LutR); free(LutB); free(LutG); printf ("libere\n");
+
+//How to free the now useless LUTs?
+//
+//free(LutR); free(LutB); free(LutG);
return(LUTRGBA);
}