X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=src%2FgdcmFile.cxx;h=af62cd8f545a8856958298eca0e2e1668bb5b47c;hb=33413fc6fb41f4fd7efbce32083f943f252e8b6f;hp=7274df46ab47f06e7da21d26b168fca987aa7f2f;hpb=35d42d4166f9dae6312ec59765e08b48f9ef946f;p=gdcm.git diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 7274df46..af62cd8f 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,6 +3,7 @@ #include "gdcmFile.h" #include "gdcmUtil.h" #include "iddcmjpeg.h" // for the 'LibIDO' Jpeg LossLess +#include "jpeg/ljpg/jpegless.h" ///////////////////////////////////////////////////////////////// /** @@ -124,7 +125,34 @@ bool gdcmFile::ReadPixelData(void* destination) { if ( fseek(fp, GetPixelOffset(), SEEK_SET) == -1 ) { CloseFile(); return false; - } + } + +// ------------------------- Compacted File (12 Bits Per Pixel) + + /* unpack 12 Bits pixels into 16 Bits pixels */ + /* 2 pixels 12bit = [0xABCDEF] */ + /* 2 pixels 16bit = [0x0ABD] + [0x0FCE] */ + + if (GetBitsAllocated()==12) { + int nbPixels = GetXSize()*GetYSize(); + unsigned char b0, b1, b2; + + for(int p=0;p> 4) << 8) + ((b0 & 0x0f) << 4) + (b1 & 0x0f); + /* A */ /* B */ /* D */ + *((unsigned short int*)destination)++ = + ((b2 & 0x0f) << 8) + ((b1 >> 4) << 4) + (b2 >> 4); + /* F */ /* C */ /* E */ + + // Troubles expected on Big-Endian processors ? + } + return(true); + } + // ------------------------- Uncompressed File @@ -143,8 +171,18 @@ bool gdcmFile::ReadPixelData(void* destination) { return true; } } + + +// ------------------------- Run Length Encoding + + if (gdcmHeader::IsRLELossLessTransferSyntax()) { + int res = (bool)gdcm_read_RLE_file (destination); + return res; + } + + - // ------------------------ Compressed File . +// ----------------- SingleFrame/Multiframe JPEG Lossless/Lossy/2000 int nb; std::string str_nb=gdcmHeader::GetPubElValByNumber(0x0028,0x0100); @@ -152,74 +190,21 @@ bool gdcmFile::ReadPixelData(void* destination) { nb = 16; } else { nb = atoi(str_nb.c_str() ); - if (nb == 12) nb =16; + if (nb == 12) nb =16; // ?? 12 should be ACR-NEMA only ? } int nBytes= nb/8; - int taille = GetXSize() * GetYSize() * GetSamplesPerPixel(); - - - // ------------------------------- JPEG LossLess : call to Jpeg Libido - - if (IsJPEGLossless() && GetZSize() == 1) { - - int ln; // Position on begining of Jpeg Pixels - fseek(fp,4,SEEK_CUR); // skipping (fffe,e000) : Basic Offset Table Item - fread(&ln,4,1,fp); - if(GetSwapCode()) - ln=SwapLong(ln); // Item length - fseek(fp,ln,SEEK_CUR); // skipping Basic Offset Table ('ln' bytes) - fseek(fp,4,SEEK_CUR); // skipping (fffe,e000) : First fragment Item Tag - fread(&ln,4,1,fp); // First fragment length (just to know) - if(GetSwapCode()) - ln=SwapLong(ln); - - ClbJpeg* jpg = _IdDcmJpegRead(fp); // TODO : find a 'full' one. - // (We use the LibIDO one :-( - if(jpg == NULL) { - CloseFile(); - return false; - } - int * dataJpg = jpg->DataImg; - - switch (nBytes) { - case 1: - { - unsigned short *dest = (unsigned short *)destination; - for (int i=0; iDataImg; - unsigned short *dest = (unsigned short *)destination; - switch (nBytes) { - case 1: - { - for (int i=0; i