X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmJpeg2000.cxx;h=079e58a96b8af6bea1beb68e1fea8b43d9efc12f;hb=eeb624df6a1661e969566c200505f3dac84f4cd6;hp=74f83d205500692bf8d32ca825067acfd1b438ae;hpb=3315facbebdc1d83c15bf021e082de0d58dbacc1;p=gdcm.git diff --git a/src/gdcmJpeg2000.cxx b/src/gdcmJpeg2000.cxx index 74f83d20..079e58a9 100644 --- a/src/gdcmJpeg2000.cxx +++ b/src/gdcmJpeg2000.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJpeg2000.cxx,v $ Language: C++ - Date: $Date: 2005/05/30 01:30:39 $ - Version: $Revision: 1.21 $ + Date: $Date: 2005/07/11 18:10:29 $ + 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 @@ -27,15 +27,20 @@ namespace gdcm //----------------------------------------------------------------------------- /** * \brief routine for JPEG decompression - * @param fp pointer to an already open file descriptor - * JPEG2000 encoded image - * @param image_buffer to receive uncompressed pixels + * @param raw raw + * @param inputdata inputdata + * @param inputlength inputlength * @return 1 on success, 0 on error - * @warning : not yet made */ bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength) { +#if 0 + std::cerr << "Inputlenght=" << inputlength << std::endl; + std::ofstream out("/tmp/jpeg2000.jpc", std::ios::binary); + out.write((char*)inputdata,inputlength); + out.close(); +#endif jas_init(); //important... jas_stream_t *jasStream = jas_stream_memopen((char *)inputdata, inputlength); @@ -62,10 +67,8 @@ bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength) int height = jas_image_cmptheight(jasImage, 0); int prec = jas_image_cmptprec(jasImage, 0); int i, j, k; - char *fmtname = jas_image_fmttostr(fmtid); - printf("%s %d %d %d %d %ld\n", fmtname, numcmpts, width, height, prec, (long) jas_image_rawsize(jasImage)); - // The following should serioulsy be rewritten I cannot belive we need to + // The following should serioulsy be rewritten I cannot believe we need to // do a per pixel decompression, there should be a way to read a full // scanline... if (prec == 8) @@ -74,8 +77,7 @@ bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength) for ( i = 0; i < height; i++) for ( j = 0; j < width; j++) for ( k= 0; k < numcmpts; k++) - *data8++ = - (uint8_t)(jas_image_readcmptsample(jasImage, k, j ,i )); + *data8++ = (uint8_t)(jas_image_readcmptsample(jasImage, k, j ,i )); } else if (prec <= 16) { @@ -83,8 +85,7 @@ bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength) for ( i = 0; i < height; i++) for ( j = 0; j < width; j++) for ( k= 0; k < numcmpts; k++) - *data16++ = - (uint16_t)(jas_image_readcmptsample(jasImage, k, j ,i )); + *data16++ = (uint16_t)(jas_image_readcmptsample(jasImage, k, j ,i )); } else if (prec <= 32) { @@ -92,8 +93,7 @@ bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength) for ( i = 0; i < height; i++) for ( j = 0; j < width; j++) for ( k= 0; k < numcmpts; k++) - *data32++ = - (uint32_t)(jas_image_readcmptsample(jasImage, k, j ,i )); + *data32++ = (uint32_t)(jas_image_readcmptsample(jasImage, k, j ,i )); } jas_image_destroy(jasImage); @@ -101,6 +101,11 @@ bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength) //FIXME //delete the jpeg temp buffer +#if 0 + std::ofstream rawout("/tmp/jpeg2000.raw"); + rawout.write((char*)raw,height*width*numcmpts*((prec+4)/8)); + rawout.close(); +#endif delete[] inputdata; return true;