X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmRLE.cxx;h=72cf33403d244acd98670b8c02ad26fb964c259b;hb=d71e2e62b38383d9b960760f6d81c4d545d59fba;hp=ab7f62f7e269d9fb1a55a7ebc7bcac96832321cf;hpb=5a6910a313a526514242a21b868c7186fca14168;p=gdcm.git diff --git a/src/gdcmRLE.cxx b/src/gdcmRLE.cxx index ab7f62f7..72cf3340 100644 --- a/src/gdcmRLE.cxx +++ b/src/gdcmRLE.cxx @@ -1,34 +1,36 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: gdcmRLE.cxx,v $ + Language: C++ + Date: $Date: 2004/06/23 03:36:24 $ + Version: $Revision: 1.19 $ + + 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 #include "gdcmFile.h" -#include /* to declare isprint() */ +#include // For 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 - * + * at which the pixel data should be copied * @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; @@ -55,7 +57,7 @@ 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; for (int i=0;i1) { - 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); - _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); } @@ -105,7 +107,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); @@ -128,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; @@ -140,27 +142,18 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) { } } memmove(image_buffer,newDest,lgrTotale); - free(newDest); + delete[] newDest; } - return(true); + return true; } - /* -------------------------------------------------------------------- */ - // - // 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) { + (void)lengthToDecode; //FIXME long ftellRes; int count; long numberOfOutputBytes=0; @@ -168,7 +161,6 @@ _gdcm_read_RLE_fragment (char ** areaToRead, ftellRes =ftell(fp); while(numberOfOutputBytes