5 #include "jpeg/ljpg/jpegless.h"
7 /////////////////////////////////////////////////////////////////
10 * \brief Constructor dedicated to writing a new DICOMV3 part10 compliant
11 * file (see SetFileName, SetDcmTag and Write)
12 * Opens (in read only and when possible) an existing file and checks
13 * for DICOM compliance. Returns NULL on failure.
14 * \Note the in-memory representation of all available tags found in
15 * the DICOM header is post-poned to first header information access.
16 * This avoid a double parsing of public part of the header when
17 * one sets an a posteriori shadow dictionary (efficiency can be
18 * seen as a side effect).
20 * @param filename file to be opened for parsing
25 gdcmFile::gdcmFile(std::string & filename)
26 :gdcmHeader(filename.c_str())
29 SetPixelDataSizeFromHeader();
32 gdcmFile::gdcmFile(const char * filename)
36 SetPixelDataSizeFromHeader();
41 * \brief calcule la longueur (in bytes) A ALLOUER pour recevoir les
42 * pixels de l'image ou DES images dans le cas d'un multiframe
44 * ATTENTION : il ne s'agit PAS de la longueur du groupe des Pixels
45 * (dans le cas d'images compressees, elle n'a pas de sens).
47 * @return longueur a allouer
49 void gdcmFile::SetPixelDataSizeFromHeader(void) {
52 str_nb=gdcmHeader::GetPubElValByNumber(0x0028,0x0100);
53 if (str_nb == GDCM_UNFOUND ) {
56 nb = atoi(str_nb.c_str() );
59 lgrTotale = lgrTotaleRaw = GetXSize() * GetYSize() * GetZSize()
60 * (nb/8)* GetSamplesPerPixel();
61 std::string str_PhotometricInterpretation =
62 gdcmHeader::GetPubElValByNumber(0x0028,0x0004);
64 /*if ( str_PhotometricInterpretation == "PALETTE COLOR " )*/
65 // pb when undealt Segmented Palette Color
72 // see PS 3.3-2003 : C.7.6.3.2.1
82 // YBR_FULL_422 (no LUT, no Palette)
88 // ex : gdcm-US-ALOKA-16.dcm
89 // 0028|1221 [OW] [Segmented Red Palette Color Lookup Table Data]
90 // 0028|1222 [OW] [Segmented Green Palette Color Lookup Table Data]
91 // 0028|1223 [OW] [Segmented Blue Palette Color Lookup Table Data]
93 // ex : OT-PAL-8-face.dcm
94 // 0028|1201 [US] [Red Palette Color Lookup Table Data]
95 // 0028|1202 [US] [Green Palette Color Lookup Table Data]
96 // 0028|1203 [US] [Blue Palette Color Lookup Table Data]
99 /////////////////////////////////////////////////////////////////
102 * \brief Returns the size (in bytes) of required memory to hold
103 * the pixel data represented in this file.
104 * @return The size of pixel data in bytes.
107 size_t gdcmFile::GetImageDataSize(void) {
112 /////////////////////////////////////////////////////////////////
115 * \brief Read pixel data from disk (optionaly decompressing) into the
116 * caller specified memory location.
117 * @param destination where the pixel data should be stored.
120 bool gdcmFile::ReadPixelData(void* destination) {
125 if ( fseek(fp, GetPixelOffset(), SEEK_SET) == -1 ) {
131 // ---------------------- Compacted File (12 Bits Per Pixel)
133 /* unpack 12 Bits pixels into 16 Bits pixels */
134 /* 2 pixels 12bit = [0xABCDEF] */
135 /* 2 pixels 16bit = [0x0ABD] + [0x0FCE] */
137 if (GetBitsAllocated()==12) {
138 int nbPixels = GetXSize()*GetYSize();
139 unsigned char b0, b1, b2;
141 unsigned short int* pdestination = (unsigned short int*)destination;
142 for(int p=0;p<nbPixels;p+=2) {
146 //Two steps is necessary to please VC++
147 *pdestination++ = ((b0 >> 4) << 8) + ((b0 & 0x0f) << 4) + (b1 & 0x0f);
148 /* A */ /* B */ /* D */
149 *pdestination++ = ((b2 & 0x0f) << 8) + ((b1 >> 4) << 4) + (b2 >> 4);
150 /* F */ /* C */ /* E */
152 // Troubles expected on Big-Endian processors ?
157 // ---------------------- Uncompressed File
160 IsImplicitVRLittleEndianTransferSyntax() ||
161 IsExplicitVRLittleEndianTransferSyntax() ||
162 IsExplicitVRBigEndianTransferSyntax() ||
163 IsDeflatedExplicitVRLittleEndianTransferSyntax() ) {
165 size_t ItemRead = fread(destination, GetPixelAreaLength(), 1, fp);
167 if ( ItemRead != 1 ) {
176 // ---------------------- Run Length Encoding
178 if (gdcmHeader::IsRLELossLessTransferSyntax()) {
179 int res = (bool)gdcm_read_RLE_file (destination);
183 // --------------- SingleFrame/Multiframe JPEG Lossless/Lossy/2000
186 std::string str_nb=gdcmHeader::GetPubElValByNumber(0x0028,0x0100);
187 if (str_nb == GDCM_UNFOUND ) {
190 nb = atoi(str_nb.c_str() );
191 if (nb == 12) nb =16; // ?? 12 should be ACR-NEMA only ?
195 int taille = GetXSize() * GetYSize() * GetSamplesPerPixel();
196 long fragmentBegining; // for ftell, fseek
198 bool jpg2000 = IsJPEG2000();
199 bool jpgLossless = IsJPEGLossless();
202 guint16 ItemTagGr,ItemTagEl;
205 // Position on begining of Jpeg Pixels
207 fread(&ItemTagGr,2,1,fp); // Reading (fffe) : Item Tag Gr
208 fread(&ItemTagEl,2,1,fp); // Reading (e000) : Item Tag El
210 ItemTagGr=SwapShort(ItemTagGr);
211 ItemTagEl=SwapShort(ItemTagEl);
215 ln=SwapLong(ln); // Basic Offset Table Item length
218 // What is it used for ?!?
219 char *BasicOffsetTableItemValue = (char *)malloc(ln+1);
220 fread(BasicOffsetTableItemValue,ln,1,fp);
223 // first Fragment initialisation
224 fread(&ItemTagGr,2,1,fp); // Reading (fffe) : Item Tag Gr
225 fread(&ItemTagEl,2,1,fp); // Reading (e000) : Item Tag El
227 ItemTagGr=SwapShort(ItemTagGr);
228 ItemTagEl=SwapShort(ItemTagEl);
231 // parsing fragments until Sequence Delim. Tag found
233 while ( ( ItemTagGr == 0xfffe) && (ItemTagEl != 0xe0dd) ) {
235 // --- for each Fragment
239 ln=SwapLong(ln); // Fragment Item length
241 fragmentBegining=ftell(fp);
243 if (jpg2000) { // JPEG 2000 : call to ???
245 res = (bool)gdcm_read_JPEG2000_file (destination); // Not Yet written
247 } // ------------------------------------- endif (JPEG2000)
249 else if (jpgLossless) { // JPEG LossLess : call to xmedcom JPEG
251 JPEGLosslessDecodeImage (fp, // Reading Fragment pixels
252 (unsigned short *)destination,
253 GetPixelSize()*8* GetSamplesPerPixel(),
255 res=1; // in order not to break the loop
257 } // ------------------------------------- endif (JPEGLossless)
259 else { // JPEG Lossy : call to IJG 6b
261 if (GetBitsStored() == 8) {
262 res = (bool)gdcm_read_JPEG_file (destination); // Reading Fragment pixels
264 res = (bool)gdcm_read_JPEG_file12 (destination);// Reading Fragment pixels
266 } // ------------------------------------- endif (JPEGLossy)
270 destination = (char *)destination + taille * nBytes; // location in user's memory
271 // for next fragment (if any)
273 fseek(fp,fragmentBegining,SEEK_SET); // To be sure we start
274 fseek(fp,ln,SEEK_CUR); // at the begining of next fragment
276 ItemTagGr = ItemTagEl =0;
277 fread(&ItemTagGr,2,1,fp); // Reading (fffe) : Item Tag Gr
278 fread(&ItemTagEl,2,1,fp); // Reading (e000) : Item Tag El
280 ItemTagGr=SwapShort(ItemTagGr);
281 ItemTagEl=SwapShort(ItemTagEl);
284 } // endWhile parsing fragments until Sequence Delim. Tag found
291 * \brief Allocates necessary memory, copies the pixel data
292 * (image[s]/volume[s]) to newly allocated zone.
293 * Transforms YBR pixels into RGB pixels if any
294 Transforms 3 planes R, G, B into a single RGB Plane
295 Transforms single Grey plane + 3 Palettes into a RGB Plane
296 * @return Pointer to newly allocated pixel data.
297 * \ NULL if alloc fails
299 void * gdcmFile::GetImageData (void) {
300 PixelData = (void *) malloc(lgrTotale);
302 GetImageDataIntoVector(PixelData, lgrTotale);
308 * \brief Allocates necessary memory, copies the pixel data
309 * (image[s]/volume[s]) to newly allocated zone.
310 * Transforms YBR pixels into RGB pixels if any
311 Transforms 3 planes R, G, B into a single RGB Plane
312 DOES NOT transform Grey plane + 3 Palettes into a RGB Plane
313 * @return Pointer to newly allocated pixel data.
314 * \ NULL if alloc fails
316 void * gdcmFile::GetImageDataRaw (void) {
318 lgrTotale /= 3; // TODO Let gdcmHeadar user a chance
319 // to get the right value
320 // Create a member lgrTotaleRaw ???
321 PixelData = (void *) malloc(lgrTotale);
323 GetImageDataIntoVectorRaw(PixelData, lgrTotale);
329 * \brief Copies at most MaxSize bytes of pixel data to caller's
331 * \warning This function was designed to avoid people that want to build
332 * a volume from an image stack to need first to get the image pixels
333 * and then move them to the volume area.
334 * It's absolutely useless for any VTK user since vtk chooses
335 * to invert the lines of an image, that is the last line comes first
336 * (for some axis related reasons?). Hence he will have
337 * to load the image line by line, starting from the end.
338 * VTK users have to call GetImageData
340 * @param destination Address (in caller's memory space) at which the
341 * pixel data should be copied
342 * @param MaxSize Maximum number of bytes to be copied. When MaxSize
343 * is not sufficient to hold the pixel data the copy is not
344 * executed (i.e. no partial copy).
345 * @return On success, the number of bytes actually copied. Zero on
346 * failure e.g. MaxSize is lower than necessary.
349 size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) {
351 size_t l = GetImageDataIntoVectorRaw (destination, MaxSize);
356 // from Lut R + Lut G + Lut B
358 unsigned char * newDest = (unsigned char *)malloc(lgrTotale);
359 unsigned char * a = (unsigned char *)destination;
361 unsigned char * lutRGBA = (unsigned char *)GetLUTRGBA();
365 memmove(newDest, destination, l);// move Gray pixels to temp area
367 for (int i=0;i<l; i++) { // Build RGB Pixels
376 // need to make RGB Pixels (?)
377 // from grey Pixels (?!)
378 // and Gray Lut (!?!)
379 // or Segmented xxx Palette Color Lookup Table Data and so on
381 // Well . I'll wait till I find such an image
383 // Oops! I get one (gdcm-US-ALOKA-16.dcm)
384 // No idea how to manage it
385 // It seems that *no Dicom Viewer* has any idea :-(
386 // Segmented xxx Palette Color are *more* than 65535 long ?!?
389 // now, it's an RGB image
390 // Lets's write it in the Header
392 // CreateOrReplaceIfExist ?
394 std::string spp = "3"; // Samples Per Pixel
395 gdcmHeader::SetPubElValByNumber(spp,0x0028,0x0002);
396 std::string rgb="RGB "; // Photometric Interpretation
397 gdcmHeader::SetPubElValByNumber(rgb,0x0028,0x0004);
398 std::string planConfig = "0"; // Planar Configuration
399 gdcmHeader::SetPubElValByNumber(planConfig,0x0028,0x0006);
401 // TODO : Drop Palette Color out of the Header?
410 * \brief Copies at most MaxSize bytes of pixel data to caller's
412 * \warning This function was designed to avoid people that want to build
413 * a volume from an image stack to need first to get the image pixels
414 * and then move them to the volume area.
415 * It's absolutely useless for any VTK user since vtk chooses
416 * to invert the lines of an image, that is the last line comes first
417 * (for some axis related reasons?). Hence he will have
418 * to load the image line by line, starting from the end.
419 * VTK users hace to call GetImageData
420 * \warning DOES NOT transform the Grey Plane + Palette Color (if any)
421 * into a single RGB Pixels Plane
422 * the (VTK) user will manage the palettes
424 * @param destination Address (in caller's memory space) at which the
425 * pixel data should be copied
426 * @param MaxSize Maximum number of bytes to be copied. When MaxSize
427 * is not sufficient to hold the pixel data the copy is not
428 * executed (i.e. no partial copy).
429 * @return On success, the number of bytes actually copied. Zero on
430 * failure e.g. MaxSize is lower than necessary.
433 size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t MaxSize) {
435 int nb, nbu, highBit, signe;
436 std::string str_nbFrames, str_nb, str_nbu, str_highBit, str_signe;
438 if ( lgrTotale > MaxSize ) {
439 dbg.Verbose(0, "gdcmFile::GetImageDataIntoVector: pixel data bigger"
440 "than caller's expected MaxSize");
444 (void)ReadPixelData(destination);
446 // Nombre de Bits Alloues pour le stockage d'un Pixel
447 str_nb = GetPubElValByNumber(0x0028,0x0100);
448 if (str_nb == GDCM_UNFOUND ) {
451 nb = atoi(str_nb.c_str() );
454 // Nombre de Bits Utilises
455 str_nbu=GetPubElValByNumber(0x0028,0x0101);
456 if (str_nbu == GDCM_UNFOUND ) {
459 nbu = atoi(str_nbu.c_str() );
462 // Position du Bit de Poids Fort
463 str_highBit=GetPubElValByNumber(0x0028,0x0102);
464 if (str_highBit == GDCM_UNFOUND ) {
467 highBit = atoi(str_highBit.c_str() );
472 str_signe=GetPubElValByNumber(0x0028,0x0103);
473 if (str_signe == GDCM_UNFOUND ) {
474 signe = 0; // default is unsigned
476 signe = atoi(str_signe.c_str() );
479 // re arange bytes inside the integer
481 SwapZone(destination, GetSwapCode(), lgrTotale, nb);
483 // to avoid pb with some xmedcon breakers images
484 if (nb==16 && nbu<nb && signe==0) {
485 int l = (int)lgrTotale / (nb/8);
486 guint16 *deb = (guint16 *)destination;
487 for(int i = 0; i<l; i++) {
494 // re arange bits inside the bytes
496 int l = (int)lgrTotale / (nb/8);
498 guint16 mask = 0xffff;
499 mask = mask >> (nb-nbu);
500 guint16 *deb = (guint16 *)destination;
501 for(int i = 0; i<l; i++) {
502 *deb = (*deb >> (nbu-highBit-1)) & mask;
505 } else if (nb == 32 ) {
506 guint32 mask = 0xffffffff;
507 mask = mask >> (nb-nbu);
508 guint32 *deb = (guint32 *)destination;
509 for(int i = 0; i<l; i++) {
510 *deb = (*deb >> (nbu-highBit-1)) & mask;
514 dbg.Verbose(0, "gdcmFile::GetImageDataIntoVector: wierd image");
519 // Just to 'see' what was actually read on disk :-(
520 // Some troubles expected
522 // f2 = fopen("SpuriousFile.raw","wb");
523 // fwrite(destination,lgrTotale,1,f2);
526 // Deal with the color
527 // -------------------
529 std::string str_PhotometricInterpretation =
530 gdcmHeader::GetPubElValByNumber(0x0028,0x0004);
532 if ( (str_PhotometricInterpretation == "MONOCHROME1 ")
533 || (str_PhotometricInterpretation == "MONOCHROME2 ") ) {
537 // Planar configuration = 0 : Pixels are already RGB
538 // Planar configuration = 1 : 3 planes : R, G, B
539 // Planar configuration = 2 : 1 gray Plane + 3 LUT
541 // Well ... supposed to be !
542 // See US-PAL-8-10x-echo.dcm: PlanarConfiguration=0,
543 // PhotometricInterpretation=PALETTE COLOR
544 // and heuristic has to be found :-(
546 int planConf=GetPlanarConfiguration(); // 0028,0006
548 // Whatever Planar Configuration is,
549 // "PALETTE COLOR " implies that we deal with the palette.
550 if (str_PhotometricInterpretation == "PALETTE COLOR ")
555 // Pixels are already RGB
561 if (str_PhotometricInterpretation == "YBR_FULL") {
563 // Warning : YBR_FULL_422 acts as RGB
564 // need to make RGB Pixels from Planes Y,cB,cR
565 // see http://lestourtereaux.free.fr/papers/data/yuvrgb.pdf
566 // for code optimisation
568 int l = GetXSize()*GetYSize();
569 int nbFrames = GetZSize();
571 unsigned char * newDest = (unsigned char*) malloc(lgrTotale);
572 unsigned char *x = newDest;
573 unsigned char * a = (unsigned char *)destination;
574 unsigned char * b = a + l;
575 unsigned char * c = b + l;
579 // TODO : Replace by the 'well known'
580 // integer computation counterpart
581 for (int i=0;i<nbFrames;i++) {
582 for (int j=0;j<l; j++) {
583 R= 1.164 *(*a-16) + 1.596 *(*c -128) + 0.5;
584 G= 1.164 *(*a-16) - 0.813 *(*c -128) - 0.392 *(*b -128) + 0.5;
585 B= 1.164 *(*a-16) + 2.017 *(*b -128) + 0.5;
590 if (R>255.0) R=255.0;
591 if (G>255.0) G=255.0;
592 if (B>255.0) B=255.0;
594 *(x++) = (unsigned char)R;
595 *(x++) = (unsigned char)G;
596 *(x++) = (unsigned char)B;
600 memmove(destination,newDest,lgrTotale);
605 // need to make RGB Pixels from R,G,B Planes
606 // (all the Frames at a time)
608 int l = GetXSize()*GetYSize()*GetZSize();
610 char * newDest = (char*) malloc(lgrTotale);
612 char * a = (char *)destination;
616 for (int j=0;j<l; j++) {
622 memmove(destination,newDest,lgrTotale);
630 // Palettes were found
631 // Let the user deal with them !
634 // now, it's an RGB image
635 // Lets's write it in the Header
637 // CreateOrReplaceIfExist ?
641 std::string spp = "3"; // Samples Per Pixel
642 gdcmHeader::SetPubElValByNumber(spp,0x0028,0x0002);
643 std::string rgb="RGB "; // Photometric Interpretation
644 gdcmHeader::SetPubElValByNumber(rgb,0x0028,0x0004);
646 std::string planConfig = "0"; // Planar Configuration
647 gdcmHeader::SetPubElValByNumber(planConfig,0x0028,0x0006);
649 // TODO : Drop Palette Color out of the Header?
658 * \brief Swap the bytes, according to swap code.
659 * \warning not end user intended
660 * @param im area to deal with
661 * @param swap swap code
662 * @param lgr Area Length
663 * @param nb Pixels Bit number
666 void gdcmFile::SwapZone(void* im, int swap, int lgr, int nb) {
684 ((unsigned short int*)im)[i]= ((((unsigned short int*)im)[i])>>8)
685 | ((((unsigned short int*)im)[i])<<8);
689 printf("valeur de SWAP (16 bits) not allowed : %d\n", swap);
700 faible= ((unsigned long int*)im)[i]&0x0000ffff; /* 4321 */
701 fort =((unsigned long int*)im)[i]>>16;
702 fort= (fort>>8) | (fort<<8);
703 faible=(faible>>8) | (faible<<8);
705 ((unsigned long int*)im)[i]=(s32<<16)|fort;
711 faible= ((unsigned long int*)im)[i]&0x0000ffff; /* 2143 */
712 fort=((unsigned long int*)im)[i]>>16;
713 fort= (fort>>8) | (fort<<8);
714 faible=(faible>>8) | (faible<<8);
716 ((unsigned long int*)im)[i]=(s32<<16)|faible;
722 faible= ((unsigned long int*)im)[i]&0x0000ffff; /* 3412 */
723 fort=((unsigned long int*)im)[i]>>16;
725 ((unsigned long int*)im)[i]=(s32<<16)|fort;
730 printf(" SWAP value (32 bits) not allowed : %d\n", swap);
735 /////////////////////////////////////////////////////////////////
739 * \warning doit-etre etre publique ?
740 * TODO : y a-t-il un inconvenient à fusioner ces 2 fonctions
743 * @param ExpectedSize
745 * @return integer acts as a boolean
747 int gdcmFile::SetImageData(void * inData, size_t ExpectedSize) {
748 SetImageDataSize(ExpectedSize);
750 lgrTotale = ExpectedSize;
755 /////////////////////////////////////////////////////////////////
758 * \brief Sets the Pixel Area size in the Header
759 * --> not-for-rats function
761 * \warning WARNING doit-etre etre publique ?
762 * TODO : y aurait il un inconvenient à fusionner ces 2 fonctions
764 * @param ImageDataSize new Pixel Area Size
765 * warning : nothing else is checked
768 void gdcmFile::SetImageDataSize(size_t ImageDataSize) {
769 std::string content1;
771 // Assumes ElValue (0x7fe0, 0x0010) exists ...
772 sprintf(car,"%d",ImageDataSize);
774 gdcmElValue*a = GetElValueByNumber(0x7fe0, 0x0010);
775 a->SetLength(ImageDataSize);
778 sprintf(car,"%d",ImageDataSize);
780 SetPubElValByNumber(content1, 0x7fe0, 0x0000);
784 /////////////////////////////////////////////////////////////////
787 * \brief Ecrit sur disque les pixels d'UNE image
788 * Aucun test n'est fait sur l'"Endiannerie" du processeur.
789 * Ca sera à l'utilisateur d'appeler son Reader correctement
790 * (Equivalent a IdImaWriteRawFile)
796 int gdcmFile::WriteRawData (std::string fileName) {
798 fp1 = fopen(fileName.c_str(),"wb");
800 printf("Echec ouverture (ecriture) Fichier [%s] \n",fileName.c_str());
803 fwrite (PixelData,lgrTotale, 1, fp1);
808 /////////////////////////////////////////////////////////////////
811 * \brief Ecrit sur disque UNE image Dicom
812 * Aucun test n'est fait sur l'"Endiannerie" du processeur.
813 * Ca fonctionnera correctement (?) sur processeur Intel
814 * (Equivalent a IdDcmWrite)
817 * @return int acts as a boolean
820 int gdcmFile::WriteDcmImplVR (std::string fileName) {
821 return WriteBase(fileName, ImplicitVR);
824 /////////////////////////////////////////////////////////////////
829 * @return int acts as a boolean
832 int gdcmFile::WriteDcmImplVR (const char* fileName) {
833 return WriteDcmImplVR (std::string (fileName));
836 /////////////////////////////////////////////////////////////////
841 * @return int acts as a boolean
844 int gdcmFile::WriteDcmExplVR (std::string fileName) {
845 return WriteBase(fileName, ExplicitVR);
848 /////////////////////////////////////////////////////////////////
851 * \brief Ecrit au format ACR-NEMA sur disque l'entete et les pixels
852 * (a l'attention des logiciels cliniques
853 * qui ne prennent en entrée QUE des images ACR ...
854 * \warning si un header DICOM est fourni en entree,
855 * les groupes < 0x0008 et les groupes impairs sont ignores)
856 * \warning Aucun test n'est fait sur l'"Endiannerie" du processeur.
857 * Ca fonctionnera correctement (?) sur processeur Intel
858 * (Equivalent a IdDcmWrite)
861 * @return int acts as a boolean
864 int gdcmFile::WriteAcr (std::string fileName) {
865 return WriteBase(fileName, ACR);
868 /////////////////////////////////////////////////////////////////
875 * @return int acts as a boolean
877 int gdcmFile::WriteBase (std::string FileName, FileType type) {
880 fp1 = fopen(FileName.c_str(),"wb");
882 printf("Echec ouverture (ecriture) Fichier [%s] \n",FileName.c_str());
886 if ( (type == ImplicitVR) || (type == ExplicitVR) ) {
888 // writing Dicom File Preamble
889 filePreamble=(char*)calloc(128,1);
890 fwrite(filePreamble,128,1,fp1);
891 fwrite("DICM",4,1,fp1);
894 // --------------------------------------------------------------
895 // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
897 // if recognition code tells us we dealt with a LibIDO image
898 // we reproduce on disk the switch between lineNumber and columnNumber
899 // just before writting ...
901 std::string rows, columns;
902 if ( filetype == ACR_LIBIDO){
903 rows = GetPubElValByNumber(0x0028, 0x0010);
904 columns = GetPubElValByNumber(0x0028, 0x0011);
905 SetPubElValByNumber(columns, 0x0028, 0x0010);
906 SetPubElValByNumber(rows , 0x0028, 0x0011);
908 // ----------------- End of Special Patch ----------------
910 gdcmHeader::Write(fp1, type);
912 // --------------------------------------------------------------
913 // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
915 // ...and we restore the Header to be Dicom Compliant again
916 // just after writting
918 if (filetype == ACR_LIBIDO){
919 SetPubElValByNumber(rows , 0x0028, 0x0010);
920 SetPubElValByNumber(columns, 0x0028, 0x0011);
922 // ----------------- End of Special Patch ----------------
924 fwrite(PixelData, lgrTotale, 1, fp1);