]> Creatis software - gdcm.git/blobdiff - src/gdcmRLE.cxx
Modif to be RedHat 7.3 compliant (?!)
[gdcm.git] / src / gdcmRLE.cxx
index 33986e46639810263615efa9677b2b320f6a06e2..4387ebcfd78bb1460a1b434c9c886a81399184ab 100644 (file)
@@ -1,33 +1,21 @@
-
+// gdcmRLE.cxx
+//-----------------------------------------------------------------------------
 #include <stdio.h>
 #include "gdcmFile.h"
 #include <ctype.h>             /* to declare isprint() */
 
 #define str2num(str, typeNum) *((typeNum *)(str))
 
-static int _gdcm_read_RLE_fragment (char ** image_buffer, 
-                                    long lengthToDecode,
-                                    long uncompressedSegmentSize, 
-                                    FILE* fp);
-// static because nothing but gdcm_read_RLE_file may call it
-
-// ----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
 /**
  * \ingroup   gdcmFile
  * \brief     Reads a 'Run Length Encoded' Dicom encapsulated file
+ * @param     fp already open File Pointer
  * @param     image_buffer destination Address (in caller's memory space) 
  *            at which the pixel data should be copied
  *   
- * @return    int acts as a Boolean 
+ * @return    Boolean 
  */
-
-// This is a debug version.
-// Forget the printf as they will be removed
-// as soon as the last Heuristics are checked
-
-// pb with RLE 16 Bits : 
-
-
 bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
    long fragmentBegining; // for ftell, fseek
    char * im = (char *)image_buffer;
@@ -96,7 +84,7 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
             RleSegmentLength[k]=RleSegmentOffsetTable[k+1]-RleSegmentOffsetTable[k];
             ftellRes=ftell(fp);
             fragmentBegining=ftell(fp);   
-            _gdcm_read_RLE_fragment (&im, RleSegmentLength[k],uncompressedSegmentSize,fp);
+            gdcm_read_RLE_fragment (&im, RleSegmentLength[k],uncompressedSegmentSize,fp);
             fseek(fp,fragmentBegining,SEEK_SET);  
             fseek(fp,RleSegmentLength[k],SEEK_CUR);        
          }
@@ -104,7 +92,7 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
       RleSegmentLength[nbRleSegments] = fragmentLength - RleSegmentOffsetTable[nbRleSegments];
       ftellRes=ftell(fp);
       fragmentBegining=ftell(fp);
-      _gdcm_read_RLE_fragment (&im, RleSegmentLength[nbRleSegments],uncompressedSegmentSize, fp);
+      gdcm_read_RLE_fragment (&im, RleSegmentLength[nbRleSegments],uncompressedSegmentSize, fp);
       fseek(fp,fragmentBegining,SEEK_SET);  
       fseek(fp,RleSegmentLength[nbRleSegments],SEEK_CUR);    
       
@@ -146,20 +134,10 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
 }
 
 
- /* -------------------------------------------------------------------- */
- //
- // RLE LossLess Fragment
- //
- /* -------------------------------------------------------------------- */
-
-   // static because nothing but gdcm_read_RLE_file can call it
-   // DO NOT doxygen !
-
-static int
-_gdcm_read_RLE_fragment (char ** areaToRead, 
-                         long lengthToDecode, 
-                         long uncompressedSegmentSize, 
-                         FILE* fp) {
+// ----------------------------------------------------------------------------
+// RLE LossLess Fragment
+int gdcmFile::gdcm_read_RLE_fragment(char **areaToRead, long lengthToDecode, 
+                                     long uncompressedSegmentSize, FILE *fp) {
    long ftellRes;
    int count;
    long numberOfOutputBytes=0;
@@ -167,7 +145,6 @@ _gdcm_read_RLE_fragment (char ** areaToRead,
    ftellRes =ftell(fp);
 
    while(numberOfOutputBytes<uncompressedSegmentSize) {
-
       ftellRes =ftell(fp);
       fread(&n,sizeof(char),1,fp);
       count=n;
@@ -189,3 +166,5 @@ _gdcm_read_RLE_fragment (char ** areaToRead,
    } 
    return 1;
 }
+
+// ----------------------------------------------------------------------------