]> Creatis software - gdcm.git/blobdiff - src/gdcmopenjpeg/libopenjpeg/jp2.c
(Try to) fix troubles with WIN32 vs _WIN32 at compile time
[gdcm.git] / src / gdcmopenjpeg / libopenjpeg / jp2.c
index 29aa311e687c8efd9c8ddae1535b152309c2b08a..7f6988d33a1ad8e3933e0d57c848f32a3aefe968 100644 (file)
@@ -81,7 +81,7 @@ Read the FTYP box - File type box
 @return Returns true if successful, returns false otherwise
 */
 static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio);
-static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, char *index);
+static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index);
 static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset);
 static void jp2_write_jp(opj_cio_t *cio);
 /**
@@ -414,12 +414,11 @@ static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) {
   return true;
 }
 
-static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, char *index) {
+static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index) {
   unsigned int j2k_codestream_offset, j2k_codestream_length;
   opj_jp2_box_t box;
 
   opj_j2k_t *j2k = jp2->j2k;
-  opj_image_t *image = jp2->image;
 
   box.init_pos = cio_tell(cio);
   cio_skip(cio, 4);
@@ -635,8 +634,6 @@ void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_
 
   /* Image Header box */
 
-  jp2->image = image;
-
   jp2->numcomps = image->numcomps;  /* NC */
   jp2->comps = (opj_jp2_comps_t*) opj_malloc(jp2->numcomps * sizeof(opj_jp2_comps_t));
   jp2->h = image->y1 - image->y0;    /* HEIGHT */
@@ -684,7 +681,6 @@ void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_
 }
 
 bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index) {
-  (void)image;
 
   /* JP2 encoding */
 
@@ -697,7 +693,7 @@ bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index)
 
   /* J2K encoding */
 
-  if(!jp2_write_jp2c(jp2, cio, index)) {
+  if(!jp2_write_jp2c(jp2, cio, image, index)) {
     opj_event_msg(jp2->cinfo, EVT_ERROR, "Failed to encode image\n");
     return false;
   }