]> Creatis software - gdcm.git/blobdiff - src/gdcmJpeg2000.cxx
ENH: Try to sync gdcm CVS and gdcm 1.2. ~2000 lines of changes, please be gentle...
[gdcm.git] / src / gdcmJpeg2000.cxx
index 7e2beccffbd28fb2672451f5dd4eaeeac622dbfc..4611a60aeba8927373739242cabd7f61cef2625b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJpeg2000.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/01/24 20:40:09 $
-  Version:   $Revision: 1.37 $
+  Date:      $Date: 2006/02/07 16:05:13 $
+  Version:   $Revision: 1.41 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include <iostream>
 #include <fstream>
 
+#if defined(__BORLANDC__)
+   #include <mem.h> // for memset
+#endif 
+
 extern "C" {
   #include <openjpeg.h>
 }
@@ -63,12 +67,13 @@ void info_callback(const char *msg, void *) {
 #define PGX_DFMT 1
 #define BMP_DFMT 2
 #define YUV_DFMT 3
+
 /*
  * Divide an integer by a power of 2 and round upwards.
  *
  * a divided by 2^b
  */
-static int int_ceildivpow2(int a, int b) {
+inline int int_ceildivpow2(int a, int b) {
   return (a + (1 << b) - 1) >> b;
 }
 
@@ -79,9 +84,9 @@ bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength)
 {
   opj_dparameters_t parameters;  /* decompression parameters */
   opj_event_mgr_t event_mgr;    /* event manager */
-  opj_image_t *image = NULL;
-  opj_dinfo_t* dinfo = NULL;  /* handle to a decompressor */
-  opj_cio_t *cio = NULL;
+  opj_image_t *image;
+  opj_dinfo_t* dinfo;  /* handle to a decompressor */
+  opj_cio_t *cio;
   unsigned char *src = (unsigned char*)inputdata; 
   int file_length = inputlength;
 
@@ -110,7 +115,7 @@ bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength)
       dinfo = opj_create_decompress(CODEC_J2K);
       
       /* catch events using our callbacks and give a local context */
-      opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);      
+      opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, NULL);      
 
       /* setup the decoder decoding parameters using user parameters */
       opj_setup_decoder(dinfo, &parameters);
@@ -121,7 +126,6 @@ bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength)
       /* decode the stream and fill the image structure */
       image = opj_decode(dinfo, cio);
       if(!image) {
-        fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
         opj_destroy_decompress(dinfo);
         opj_cio_close(cio);
         return 1;
@@ -132,8 +136,6 @@ bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength)
 
   /* free the memory containing the code-stream */
   delete[] src;  //FIXME
-  src = NULL;
-
 
    // Copy buffer
    for (int compno = 0; compno < image->numcomps; compno++)