]> Creatis software - gdcm.git/blobdiff - src/gdcmRLE.cxx
Cosmetic modifs to be more Coding style compliant
[gdcm.git] / src / gdcmRLE.cxx
index 2f38ae1756c911ec17335a9ad9e14e6e5330f939..730a2b5776ea9632d85a96acb30d222c03c21cc0 100644 (file)
@@ -1,8 +1,24 @@
-// gdcmRLE.cxx
-//-----------------------------------------------------------------------------
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmRLE.cxx,v $
+  Language:  C++
+  Date:      $Date: 2004/09/24 11:39:21 $
+  Version:   $Revision: 1.22 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+
 #include <stdio.h>
 #include "gdcmFile.h"
-#include <ctype.h>             // to declare isprint()
+#include <ctype.h>     // For isprint()
 
 #define str2num(str, typeNum) *((typeNum *)(str))
 
  *            at which the pixel data should be copied 
  * @return    Boolean 
  */
-bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
+bool gdcmFile::gdcm_read_RLE_file (FILE* fp,void* image_buffer) {
    long fragmentBegining; // for ftell, fseek
    char * im = (char *)image_buffer;
 
    long RleSegmentLength[15],fragmentLength,uncompressedSegmentSize;;
    long ftellRes, ln;
-   guint32 nbRleSegments;
-   guint32 RleSegmentOffsetTable[15];
-   guint16 ItemTagGr,ItemTagEl;
+   uint32_t nbRleSegments;
+   uint32_t RleSegmentOffsetTable[15];
+   uint16_t ItemTagGr,ItemTagEl;
    uncompressedSegmentSize=Header->GetXSize()*Header->GetYSize();
    ftellRes=ftell(fp);
    // Basic Offset Table with Item Value
@@ -41,11 +57,11 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
       ln=Header->SwapLong(ln);    // Basic Offset Table Item Lentgh
    if (ln != 0) {
       // What is it used for ??
-      char * BasicOffsetTableItemValue= (char *)malloc(ln+1);
+      char * BasicOffsetTableItemValue= new char[ln+1];
       fread(BasicOffsetTableItemValue,ln,1,fp); 
-      guint32 a;
+      uint32_t a;
       for (int i=0;i<ln;i+=4){
-         a=str2num(&BasicOffsetTableItemValue[i],guint32);
+         a=str2num(&BasicOffsetTableItemValue[i],uint32_t);
       }        
    }
 
@@ -79,7 +95,7 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
       }
 
       if (nbRleSegments>1) { 
-         for(int k=1; k<=nbRleSegments-1; k++) { // reading RLE Segments
+         for(unsigned int k=1; k<=nbRleSegments-1; k++) { // reading RLE Segments
             RleSegmentLength[k]=RleSegmentOffsetTable[k+1]-RleSegmentOffsetTable[k];
             ftellRes=ftell(fp);
             fragmentBegining=ftell(fp);   
@@ -114,7 +130,7 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
       int l = Header->GetXSize()*Header->GetYSize();
       int nbFrames = Header->GetZSize();
 
-      char * newDest = (char*) malloc(l*nbFrames*2);
+      char * newDest = new char[l*nbFrames*2];
       char *x  = newDest;
       char * a = (char *)image_buffer;
       char * b = a + l;
@@ -125,18 +141,19 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
             *(x++) = *(b++);
          }
       }
-      memmove(image_buffer,newDest,lgrTotale);
-      free(newDest);   
+      memmove(image_buffer,newDest,ImageDataSize);
+      delete[] newDest;
    }
       
-   return(true);
+   return true;
 }
 
 
 // ----------------------------------------------------------------------------
 // RLE LossLess Fragment
-int gdcmFile::gdcm_read_RLE_fragment(char **areaToRead, long lengthToDecode, 
-                                     long uncompressedSegmentSize, FILE *fp) {
+int gdcmFile::gdcm_read_RLE_fragment(char** areaToRead, long lengthToDecode, 
+                                     long uncompressedSegmentSize, FILE* fp) {
+   (void)lengthToDecode; //FIXME
    long ftellRes;
    int count;
    long numberOfOutputBytes=0;