X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmJpeg2000.cxx;h=51f1b050c7f32b9bc8914c0b57dc75b7d3b4957b;hb=6b17eb062f567984bf36876ddbb980731b603855;hp=aa73b48a93344f32642e75e6ac345877e1f2b0a4;hpb=2329c3cbf7cc86aa2c8410756927f0dcf3941441;p=gdcm.git diff --git a/src/gdcmJpeg2000.cxx b/src/gdcmJpeg2000.cxx index aa73b48a..51f1b050 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/22 18:38:52 $ - Version: $Revision: 1.20 $ + Date: $Date: 2005/06/07 20:23:13 $ + Version: $Revision: 1.24 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -27,22 +27,17 @@ 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 (std::ifstream* fp, void* raw, size_t inputlength) +bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength) { jas_init(); //important... - // FIXME this is really ugly but it seems I have to load the complete - // jpeg2000 stream to use jasper: - uint8_t *inputdata = new uint8_t[inputlength]; - //fp is already 'seek' to proper pos - fp->read((char*)inputdata, inputlength); - jas_stream_t *jasStream = jas_stream_memopen((char *)inputdata, inputlength); + jas_stream_t *jasStream = + jas_stream_memopen((char *)inputdata, inputlength); int fmtid; if ((fmtid = jas_image_getfmt(jasStream)) < 0) @@ -66,8 +61,6 @@ bool gdcm_read_JPEG2000_file (std::ifstream* fp, void* raw, 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 // do a per pixel decompression, there should be a way to read a full @@ -78,8 +71,7 @@ bool gdcm_read_JPEG2000_file (std::ifstream* fp, void* raw, 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) { @@ -87,8 +79,7 @@ bool gdcm_read_JPEG2000_file (std::ifstream* fp, void* raw, 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) { @@ -96,8 +87,7 @@ bool gdcm_read_JPEG2000_file (std::ifstream* fp, void* raw, 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);