+2005-01-13 Jean-Pierre Roux <jpr@creatis.univ-lyon1.fr>
+ * ENH - Comment out Mathieu's (dangerous) Super Hack
+ for dealing with BIGENDIAN processors
+ - Move equivalent stuff to BinEntry::WriteContent
+ When necessary, 16 Bits Pixels are swapped in a small buffer
+ and then written. This avoid allocating a huge buffer, in
+ PixelWriteConveror, and avoid modifying the Pixel Area.
+ Note :
+ Probabely, the same operation will have to be done when we want
+ to write image with Big Endian Transfert Syntax,
+ and we are working onj Little Endian Processor
+
2005-01-14 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
* src/gdcmDocument.[h|cxx] : comment all methods concerning a flat hash
table.
Program: gdcm
Module: $RCSfile: gdcmBinEntry.cxx,v $
Language: C++
- Date: $Date: 2005/01/11 20:49:44 $
- Version: $Revision: 1.46 $
+ Date: $Date: 2005/01/14 15:06:37 $
+ Version: $Revision: 1.47 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @param filetype type of the file to be written
*/
void BinEntry::WriteContent(std::ofstream *fp, FileType filetype)
-{
+{
+#define BUFFER_SIZE 4096
DocEntry::WriteContent(fp, filetype);
void* binArea = GetBinArea();
int lgr = GetLength();
- if (binArea)
+ if (binArea) // the binArea was *actually* loaded
{
- // there is a 'non string' LUT, overlay, etc
+
+ // TODO FIME
+ // Probabely, the same operation will have to be done when we want
+ // to write image with Big Endian Transfert Syntax,
+ // and we are working onj Little Endian Processor
+
+#ifdef GDCM_WORDS_BIGENDIAN
+ // Be carefull with *any* 16 bits words 'binEntries !'
+ // if ( GetVR() == "OW") // to be used later
+
+ // TODO FIXME Right now, we only care of Pixels element
+
+ // 8 Bits Pixels *are* OB, 16 Bits Pixels *are* OW
+ // -value forced while Reading process-
+ if (GetGroup == 0x7fe0 && GetVR() == "OW")
+ {
+ unit16_t *currPosition = (uint16_t *)binArea;
+
+ // TODO FIXME : Maybe we should allocate somewhere a static buffer,
+ // in order not to have to alloc/delete for almost every BinEntry ...
+ unit16_t *buffer = new uint16[BUFFER_SIZE];
+
+ // how many BUFFER_SIZE long pieces in binArea ?
+ int nbPieces = lgr/BUFFER_SIZE/2; //(16 bits = 2 Bytes)
+ for (int j=0;j<nbPieces;j++)
+ {
+ for (int i = 0; i < BUFFER_SIZE/2; i++)
+ {
+ buffer[i] = (uint16_t *)binArea[i] >> 8
+ | (uint16_t *)binArea[i] << 8;
+ }
+ fp->write ( (char*)currPosition, BUFFER_SIZE );
+ currPosition += BUFFER_SIZE/2;
+ }
+ int remainingSize = lgr%BUFFER_SIZE;
+ if ( remainingSize != 0)
+ {
+ fp->write ( (char*)currPosition, remainingSize );
+ }
+ delete buffer;
+ }
+ else
+ {
+ // For any other VR, BinEntry is re-written as-is
+ fp->write ( (char*)binArea, lgr );
+ }
+#else
fp->write ( (char*)binArea, lgr ); // Elem value
+#endif //GDCM_WORDS_BIGENDIAN
+
}
else
{
Program: gdcm
Module: $RCSfile: gdcmHeader.cxx,v $
Language: C++
- Date: $Date: 2005/01/11 23:06:35 $
- Version: $Revision: 1.231 $
+ Date: $Date: 2005/01/14 15:06:37 $
+ Version: $Revision: 1.232 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
}
}
+/*
#ifdef GDCM_WORDS_BIGENDIAN
- // Super Duper hack that will make gdcm a BOMB ! but should
+ // Super Super hack that will make gdcm a BOMB ! but should
// Fix temporarily the dashboard
- BinEntry *b = GetBinEntry(0x7fe0,0x0010);
- if ( GetEntry(0x0028,0x0100) == "16")
+ BinEntry *b = GetBinEntry(GrPixel,NumPixel);
+ if ( GetPixelSize() == 16 )
{
uint16_t *im16 = (uint16_t*)b->GetBinArea();
int lgr = b->GetLength();
}
}
#endif //GDCM_WORDS_BIGENDIAN
+*/
Document::WriteContent(fp,filetype);
+/*
#ifdef GDCM_WORDS_BIGENDIAN
// Flip back the pixel ... I told you this is a hack
- if ( GetEntry(0x0028,0x0100) == "16")
+ if ( GetPixelSize() == 16 )
{
uint16_t *im16 = (uint16_t*)b->GetBinArea();
int lgr = b->GetLength();
}
}
#endif //GDCM_WORDS_BIGENDIAN
+*/
fp->close();
delete fp;
Program: gdcm
Module: $RCSfile: gdcmPixelReadConvert.cxx,v $
Language: C++
- Date: $Date: 2005/01/13 09:24:08 $
- Version: $Revision: 1.26 $
+ Date: $Date: 2005/01/14 15:06:37 $
+ Version: $Revision: 1.27 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/**
* \brief Reads from disk the Pixel Data of JPEG Dicom encapsulated
- * file and decompress it. This funciton assumes that each
+ * file and decompress it. This function assumes that each
* jpeg fragment contains a whole frame (jpeg file).
* @param fp File Pointer
* @return Boolean
else
{
// other JPEG lossy not supported
- gdcmErrorMacro( "Unknown jpeg lossy compression ");
+ gdcmErrorMacro( "Unsupported jpeg lossy compression ");
delete [] buffer;
return false;
}
else
{
// other JPEG lossy not supported
- gdcmErrorMacro( "Unknown jpeg lossy compression ");
+ gdcmErrorMacro( "Unsupported jpeg lossy compression ");
delete [] buffer;
return false;
}
// [Bin|Val]Entry occurence migth have been hindered (read simply NOT
// loaded). Hence, we first try to obtain the LUTs data from the header
// and when this fails we read the LUTs data directely from disk.
- /// \todo Reading a [Bin|Val]Entry directly from disk is a kludge.
+ /// \TODO Reading a [Bin|Val]Entry directly from disk is a kludge.
/// We should NOT bypass the [Bin|Val]Entry class. Instead
/// an access to an UNLOADED content of a [Bin|Val]Entry occurence
/// (e.g. BinEntry::GetBinArea()) should force disk access from
LutRedData = (uint8_t*)header->GetEntryBinArea( 0x0028, 0x1201 );
if ( ! LutRedData )
{
- gdcmVerboseMacro( "Unable to read red LUT data" );
+ gdcmVerboseMacro( "Unable to read Red LUT data" );
}
////// Green round:
LutGreenData = (uint8_t*)header->GetEntryBinArea(0x0028, 0x1202 );
if ( ! LutGreenData)
{
- gdcmVerboseMacro( "Unable to read green LUT data" );
+ gdcmVerboseMacro( "Unable to read Green LUT data" );
}
////// Blue round:
LutBlueData = (uint8_t*)header->GetEntryBinArea( 0x0028, 0x1203 );
if ( ! LutBlueData )
{
- gdcmVerboseMacro( "Unable to read blue LUT data" );
+ gdcmVerboseMacro( "Unable to read Blue LUT data" );
}
}
&lengthR, &debR, &nbitsR );
if( nbRead != 3 )
{
- gdcmVerboseMacro( "Wrong red LUT descriptor" );
+ gdcmVerboseMacro( "Wrong Red LUT descriptor" );
}
int lengthG; // Green LUT length in Bytes
&lengthG, &debG, &nbitsG );
if( nbRead != 3 )
{
- gdcmVerboseMacro( "Wrong green LUT descriptor" );
+ gdcmVerboseMacro( "Wrong Green LUT descriptor" );
}
int lengthB; // Blue LUT length in Bytes
&lengthB, &debB, &nbitsB );
if( nbRead != 3 )
{
- gdcmVerboseMacro( "Wrong blue LUT descriptor" );
+ gdcmVerboseMacro( "Wrong Blue LUT descriptor" );
}
////////////////////////////////////////////////////////
// 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 (useless ?)overhead
+ // We give up the checking to avoid some (useless ?) overhead
// (optimistic asumption)
int i;
uint8_t* a = LutRGBA + 0;