]> Creatis software - gdcm.git/commitdiff
ENH: Backport from openjpeg CVS
authormalaterre <malaterre>
Wed, 25 Jan 2006 16:18:47 +0000 (16:18 +0000)
committermalaterre <malaterre>
Wed, 25 Jan 2006 16:18:47 +0000 (16:18 +0000)
src/gdcmopenjpeg/codec/CMakeLists.txt
src/gdcmopenjpeg/codec/convert.c
src/gdcmopenjpeg/libopenjpeg/CMakeLists.txt
src/gdcmopenjpeg/libopenjpeg/event.c
src/gdcmopenjpeg/libopenjpeg/fix.c
src/gdcmopenjpeg/libopenjpeg/openjpeg.h

index 8d8ad34e81d1192473bfd24018a4b37bd9d2431d..ee496e33a488269a56ecdc65bccc5f21d02a3697 100644 (file)
@@ -33,103 +33,10 @@ INCLUDE_DIRECTORIES(
 # Loop over all executables:
 FOREACH(exe j2k_to_image image_to_j2k)
   ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
-  TARGET_LINK_LIBRARIES(${exe} gdcmopenjpeg)
+  TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg)
   IF(UNIX)
     TARGET_LINK_LIBRARIES(${exe} -lm)
   ENDIF(UNIX)
 ENDFOREACH(exe)
 
-## $Id: CMakeLists.txt,v 1.2 2005/10/24 18:40:55 malaterre Exp $
-##
-## makefile for OpenJPEG codec
-#
-#OPENJPEG_DIR = ../libopenjpeg
-#
-#ifndef DEBUG
-#  LDFLAGS = -s -lm
-#else
-#  LDFLAGS = -lm
-#endif
-#
-#CFLAGS = -Wall -O3 -fno-strength-reduce -fomit-frame-pointer -I$(OPENJPEG_DIR)
-#
-#OBJ_DIR_W32 = obj.w32
-#BIN_DIR_W32 = bin.w32
-#LIB_DIR_W32 = $(OPENJPEG_DIR)/lib.w32
-#
-#ifdef MINGW32
-#  CC = i386-mingw32-gcc
-#  CFLAGS += -DDONT_HAVE_GETOPT
-#  OBJ_DIR = $(OBJ_DIR_W32)
-#  BIN_DIR = $(BIN_DIR_W32)
-#  LIB_DIR = lib.w32
-#  all:   $(BIN_DIR) $(OBJ_DIR) $(LIB_DIR) \
-#   $(addprefix $(BIN_DIR)/,j2k_to_image.exe image_to_j2k.exe)
-#else
-#  CC = gcc
-#  OBJ_DIR = obj
-#  BIN_DIR = bin
-#  LIB_DIR = lib
-#  all:   $(BIN_DIR) $(OBJ_DIR) $(LIB_DIR) \
-#     $(addprefix $(BIN_DIR)/,j2k_to_image image_to_j2k)
-#endif
-#
-#ifdef DYNAMIC
-#  ifdef MINGW32
-#    LIB_OPENJPEG = $(LIB_DIR)/libopenjpeg.dll
-#    LDFLAGS += -L$(LIB_DIR) -lopenjpeg
-#  else
-#    LIB_OPENJPEG = $(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.so
-#    LDFLAGS += -L$(OPENJPEG_DIR)/$(LIB_DIR) -lopenjpeg
-#  endif
-#else
-#  LIB_OPENJPEG = $(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.a
-#  LDFLAGS += $(LIB_OPENJPEG)
-#endif
-#
-#$(BIN_DIR):
-#   mkdir $(BIN_DIR)
-#
-#$(OBJ_DIR):
-#   mkdir $(OBJ_DIR)
-#
-#$(LIB_DIR):   
-#   mkdir $(LIB_DIR)
-#
-#$(LIB_DIR)/libopenjpeg.dll: $(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.dll
-#   ln -sf ../$< $@
-#$(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.dll:
-#   cd $(OPENJPEG_DIR) && \
-#   $(MAKE) $(OBJ_DIR) $(LIB_DIR) $(LIB_DIR)/libopenjpeg.dll
-#$(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.a:
-#   cd $(OPENJPEG_DIR) && \
-#   $(MAKE) $(OBJ_DIR) $(LIB_DIR) $(LIB_DIR)/libopenjpeg.a
-#$(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.so:
-#   cd $(OPENJPEG_DIR) && \
-#   $(MAKE) $(LIB_DIR) $(LIB_DIR)/libopenjpeg.so
-#
-#$(OBJ_DIR)/%.o:
-#   $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
-#
-#$(OBJ_DIR)/getopt.o:      compat/getopt.c
-#$(OBJ_DIR)/convert.o:      convert.c
-#$(OBJ_DIR)/j2k_to_image.o:   j2k_to_image.c
-#$(OBJ_DIR)/image_to_j2k.o:   image_to_j2k.c convert.h
-#
-#J2I_OBJS = $(addprefix $(OBJ_DIR)/,j2k_to_image.o)
-#I2J_OBJS = $(addprefix $(OBJ_DIR)/,image_to_j2k.o convert.o)
-#
-#$(BIN_DIR)/j2k_to_image:   $(J2I_OBJS) $(LIB_OPENJPEG)
-#   ${CC} -o $@  $(J2I_OBJS) ${LDFLAGS} 
-#
-#$(BIN_DIR)/image_to_j2k:   $(I2J_OBJS) $(LIB_OPENJPEG)
-#   ${CC} -o $@  $(I2J_OBJS) ${LDFLAGS} 
-#
-#$(BIN_DIR)/j2k_to_image.exe:   $(J2I_OBJS) $(LIB_OPENJPEG)
-#   ${CC} -o $@  $(J2I_OBJS) ${LDFLAGS} 
-#
-#$(BIN_DIR)/image_to_j2k.exe:   $(I2J_OBJS) $(LIB_OPENJPEG) $(OBJ_DIR)/getopt.o
-#   ${CC} -o $@  $(I2J_OBJS) ${LDFLAGS} $(OBJ_DIR)/getopt.o
-#
-#clean:
-#   rm -f $(BIN_DIR_W32)/* $(BIN_DIR)/* $(OBJ_DIR_W32)/* $(OBJ_DIR)/*
+
index b65dd064bdc72715a690bff1baaf7fcd9470eb26..6e2ef095adbdf866d00783319ce712c7bff90fa9 100644 (file)
@@ -844,7 +844,6 @@ opj_image_t* pnmtoimage(char *filename, opj_cparameters_t *parameters) {
   opj_image_cmptparm_t cmptparm[3];  /* maximum of 3 components */
   opj_image_t * image = NULL;
   char value;
-  char comment[256];
 
   f = fopen(filename, "rb");
   if (!f) {
@@ -859,64 +858,14 @@ opj_image_t* pnmtoimage(char *filename, opj_cparameters_t *parameters) {
   switch(value) {
     case '2':  /* greyscale image type */
     case '5':
-    {
       numcomps = 1;
       color_space = CLRSPC_GRAY;
-
-      fgetc(f);
-
-      if (fgetc(f) == '#') {
-        /* skip comments */
-        fseek(f, 0, SEEK_SET);
-        if (value == '2') {
-          fscanf(f, "P2\n");
-        } else if (value == '5') {
-          fscanf(f, "P5\n");
-        }
-        fgets(comment, 256, f);
-        fscanf(f, "%d %d\n255", &w, &h);
-      } else {
-        fseek(f, 0, SEEK_SET);
-        if (value == '2') {
-          fscanf(f, "P2\n%d %d\n255", &w, &h);
-        } else if (value == '5') {
-          fscanf(f, "P5\n%d %d\n255", &w, &h);
-        }
-      }
-      
-      fgetc(f);  /* <cr><lf> */
-    }
     break;
 
     case '3':  /* RGB image type */
     case '6':
-    {
       numcomps = 3;
       color_space = CLRSPC_SRGB;
-
-      fgetc(f);
-
-      if (fgetc(f) == '#') {
-        /* skip comments */
-        fseek(f, 0, SEEK_SET);
-        if (value == '3') {
-          fscanf(f, "P3\n");
-        } else if (value == '6') {
-          fscanf(f, "P6\n");
-        }
-        fgets(comment, 256, f);
-        fscanf(f, "%d %d\n255", &w, &h);
-      } else {
-        fseek(f, 0, SEEK_SET);
-        if (value == '3') {
-          fscanf(f, "P3\n%d %d\n255", &w, &h);
-        } else if (value == '6') {
-          fscanf(f, "P6\n%d %d\n255", &w, &h);
-        }
-      }
-      
-      fgetc(f);  /* <cr><lf> */
-    }
     break;
 
     default:
@@ -924,6 +873,15 @@ opj_image_t* pnmtoimage(char *filename, opj_cparameters_t *parameters) {
       return NULL;
   }
 
+    fgetc(f);
+    
+    /* skip comments */
+    while(fgetc(f) == '#') while(fgetc(f) != '\n');
+    
+    fseek(f, -1, SEEK_CUR);
+    fscanf(f, "%d %d\n255", &w, &h);      
+    fgetc(f);  /* <cr><lf> */
+    
   /* initialize image components */
   memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
   for(i = 0; i < numcomps; i++) {
index 6b0baebeb771214a4a085a060c7d5ab882498dd9..08a072edfaa98edbedeac0a22bd270f97092db46 100644 (file)
@@ -31,6 +31,5 @@ IF (WIN32)
   ENDIF (BUILD_SHARED_LIBS)
 ENDIF (WIN32)
 
-ADD_LIBRARY(${PARENT_PREFIX}openjpeg ${openjpeg_SRCS})
-
+ADD_LIBRARY(${OPJ_PREFIX}openjpeg ${openjpeg_SRCS})
 
index 179d32f287b5391c86e069e768ab96c633dbe01a..7e7c52f2589fe589008235e13679a7485299233c 100644 (file)
@@ -30,7 +30,7 @@
      Utility functions
    ==========================================================*/
 
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
 static char*
 i2a(unsigned i, char *a, unsigned r) {
   if (i/r > 0) a = i2a(i/r,a,r);
index 21d440088384981de44afacef4f4d8b862b8df81..e9ba82be8a39d3a886ebedafdffa388f6ccc5b8d 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "fix.h"
 
-#ifdef WIN32
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 #define int64 __int64
 #else
 #define int64 long long
index 058198d07fc47621da422e11badd36989591ffcc..d7f7413294dfdbc69366e629b6d1f8bda5d052b5 100644 (file)
 
 #define OPENJPEG_VERSION "1.0.0"
 
+#if defined(_WIN32) && !defined (OPJ_STATIC)
+#ifdef OPJ_SHARED
+#define OPJ_EXPORT __declspec(dllexport)
+#else
+#define OPJ_EXPORT __declspec(dllimport)
+#endif
+#else
+#ifdef OPJ_STATIC
+#define OPJ_EXPORT extern
+#else
+#define OPJ_EXPORT
+#endif
+#endif
+
 /* 
 ==========================================================
    Compiler directives
@@ -461,13 +475,13 @@ Create an image
 @param clrspc image color space
 @return returns a new image structure if successful, returns NULL otherwise
 */
-opj_image_t *opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
+OPJ_EXPORT opj_image_t *opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
 
 /**
 Deallocate any resources associated with an image
 @param image image to be destroyed
 */
-void opj_image_destroy(opj_image_t *image);
+OPJ_EXPORT void opj_image_destroy(opj_image_t *image);
 
 /* 
 ==========================================================
@@ -486,20 +500,20 @@ to contain encoded data.
 @param length Reading: buffer length. Writing: 0
 @return Returns a CIO handle if successful, returns NULL otherwise
 */
-opj_cio_t* opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
+OPJ_EXPORT opj_cio_t* opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
 
 /**
 Close and free a CIO handle
 @param cio CIO handle to free
 */
-void opj_cio_close(opj_cio_t *cio);
+OPJ_EXPORT void opj_cio_close(opj_cio_t *cio);
 
 /**
 Get position in byte stream
 @param cio CIO handle
 @return Returns the position in bytes
 */
-int cio_tell(opj_cio_t *cio);
+OPJ_EXPORT int cio_tell(opj_cio_t *cio);
 /**
 Set position in byte stream
 @param cio CIO handle
@@ -513,7 +527,7 @@ void cio_seek(opj_cio_t *cio, int pos);
 ==========================================================
 */
 
-opj_event_mgr_t* opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
+OPJ_EXPORT opj_event_mgr_t* opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
 
 /* 
 ==========================================================
@@ -525,42 +539,42 @@ Creates a J2K/JPT/JP2 decompression structure
 @param format Decoder to select
 @return Returns a handle to a decompressor if successful, returns NULL otherwise
 */
-opj_dinfo_t* opj_create_decompress(OPJ_CODEC_FORMAT format);
+OPJ_EXPORT opj_dinfo_t* opj_create_decompress(OPJ_CODEC_FORMAT format);
 /**
 Destroy a decompressor handle
 @param dinfo decompressor handle to destroy
 */
-void opj_destroy_decompress(opj_dinfo_t *dinfo);
+OPJ_EXPORT void opj_destroy_decompress(opj_dinfo_t *dinfo);
 /**
 Set decoding parameters to default values
 @param parameters Decompression parameters
 */
-void opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
+OPJ_EXPORT void opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
 /**
 Setup the decoder decoding parameters using user parameters.
 Decoding parameters are returned in j2k->cp. 
 @param dinfo decompressor handle
 @param parameters decompression parameters
 */
-void opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
+OPJ_EXPORT void opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
 /**
 Decode an image from a JPEG-2000 codestream
 @param dinfo decompressor handle
 @param cio Input buffer stream
 @return Returns a decoded image if successful, returns NULL otherwise
 */
-opj_image_t* opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
+OPJ_EXPORT opj_image_t* opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
 /**
 Creates a J2K/JP2 compression structure
 @param format Coder to select
 @return Returns a handle to a compressor if successful, returns NULL otherwise
 */
-opj_cinfo_t* opj_create_compress(OPJ_CODEC_FORMAT format);
+OPJ_EXPORT opj_cinfo_t* opj_create_compress(OPJ_CODEC_FORMAT format);
 /**
 Destroy a compressor handle
 @param cinfo compressor handle to destroy
 */
-void opj_destroy_compress(opj_cinfo_t *cinfo);
+OPJ_EXPORT void opj_destroy_compress(opj_cinfo_t *cinfo);
 /**
 Set encoding parameters to default values, that means : 
 <ul>
@@ -582,14 +596,14 @@ Set encoding parameters to default values, that means :
 </ul>
 @param parameters Compression parameters
 */
-void opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
+OPJ_EXPORT void opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
 /**
 Setup the encoder parameters using the current image and using user parameters. 
 @param cinfo compressor handle
 @param parameters compression parameters
 @param image input filled image
 */
-void opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
+OPJ_EXPORT void opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
 /**
 Encode an image into a JPEG-2000 codestream
 @param cinfo compressor handle
@@ -598,7 +612,7 @@ Encode an image into a JPEG-2000 codestream
 @param index Name of the index file if required, NULL otherwise
 @return Returns true if successful, returns false otherwise
 */
-bool opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
+OPJ_EXPORT bool opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
 
 #ifdef __cplusplus
 }