diff options
| author | Antonin Descampe <antonin@gmail.com> | 2010-10-05 10:33:15 +0000 |
|---|---|---|
| committer | Antonin Descampe <antonin@gmail.com> | 2010-10-05 10:33:15 +0000 |
| commit | eeefefd56cb3edddefb73141733fd1e757c4b798 (patch) | |
| tree | 4727958764c4c348762c043c2efbb7470a9ffcca /codec | |
| parent | 531c0cf26f0c327b42a5caa79725e4afeb98768d (diff) | |
Added files to let people build openjpeg with configure tools ; Added makefiles to let people manually build openjpeg on *nix platforms ; Removed obsolete Makefiles ; Renamed dirent.h to windirent.h ; Made optional the PNG, TIFF, and LCMS support in CMake files ; Added opj_config* files to configure openjpeg before building it (opj_config.h generated by configure, cmake, or manually by the user) ; Renamed this file from ChangeLog to CHANGES ; Renamed License.txt to LICENSE ; Updated README files ; Added INSTALL and LICENSE files ; Added man pages
Diffstat (limited to 'codec')
| -rw-r--r-- | codec/CMakeLists.txt | 20 | ||||
| -rw-r--r-- | codec/Makefile | 17 | ||||
| -rw-r--r-- | codec/Makefile.am | 49 | ||||
| -rw-r--r-- | codec/Makefile.in | 609 | ||||
| -rw-r--r-- | codec/Makefile.nix | 66 | ||||
| -rw-r--r-- | codec/README | 8 | ||||
| -rw-r--r-- | codec/convert.c | 695 | ||||
| -rw-r--r-- | codec/image_to_j2k.c | 22 | ||||
| -rw-r--r-- | codec/j2k_dump.c | 11 | ||||
| -rw-r--r-- | codec/j2k_to_image.c | 19 | ||||
| -rw-r--r-- | codec/windirent.h (renamed from codec/dirent.h) | 0 |
11 files changed, 1218 insertions, 298 deletions
diff --git a/codec/CMakeLists.txt b/codec/CMakeLists.txt index 563ae6dd..e24ac470 100644 --- a/codec/CMakeLists.txt +++ b/codec/CMakeLists.txt @@ -23,17 +23,25 @@ ENDIF(NOT BUILD_SHARED_LIBS) # Headers file are located here: INCLUDE_DIRECTORIES( ${OPENJPEG_SOURCE_DIR}/libopenjpeg + ${LCMS_INCLUDE_DIR} ) - -FIND_PACKAGE(TIFF REQUIRED) -FIND_PACKAGE(PNG REQUIRED) -INCLUDE_DIRECTORIES( ${PNG_INCLUDE_DIR} ) -INCLUDE_DIRECTORIES( ${TIFF_INCLUDE_DIR} ) +IF(PNG_FOUND) + INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR}) +ENDIF(PNG_FOUND) +IF(TIFF_FOUND) + INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR}) +ENDIF(TIFF_FOUND) # Loop over all executables: FOREACH(exe j2k_to_image image_to_j2k j2k_dump) ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS}) - TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg ${TIFF_LIBRARIES} ${PNG_LIBRARIES}) + TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg ${LCMS_LIB}) + IF(PNG_FOUND) + TARGET_LINK_LIBRARIES(${exe} ${PNG_LIBRARIES}) + ENDIF(PNG_FOUND) + IF(TIFF_FOUND) + TARGET_LINK_LIBRARIES(${exe} ${TIFF_LIBRARIES}) + ENDIF(TIFF_FOUND) ADD_TEST(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe}) # calling those exe without option will make them fail always: SET_TESTS_PROPERTIES(${exe} PROPERTIES WILL_FAIL TRUE) diff --git a/codec/Makefile b/codec/Makefile deleted file mode 100644 index b3c93b0e..00000000 --- a/codec/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# Makefile for the main OpenJPEG codecs: j2k_to_image and image_to_j2k - -CFLAGS = -Wall -O3 -lstdc++ # -g -p -pg - -all: j2k_to_image image_to_j2k j2k_dump - -j2k_to_image: j2k_to_image.c ../libopenjpeg.a - gcc $(CFLAGS) compat/getopt.c index.c convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff -lpng - -image_to_j2k: image_to_j2k.c ../libopenjpeg.a - gcc $(CFLAGS) compat/getopt.c index.c convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff -lpng - -j2k_dump: j2k_dump.c ../libopenjpeg.a - gcc $(CFLAGS) compat/getopt.c index.c j2k_dump.c -o j2k_dump -L.. -lopenjpeg -I ../libopenjpeg/ -lm - -clean: - rm -f j2k_to_image image_to_j2k j2k_dump diff --git a/codec/Makefile.am b/codec/Makefile.am new file mode 100644 index 00000000..b0837fa9 --- /dev/null +++ b/codec/Makefile.am @@ -0,0 +1,49 @@ +COMPILERFLAGS = -Wall +USERLIBS = -lm +INCLUDES = -I.. -I. -I../libopenjpeg + +if with_libjpwl +USERLIBS += -L../jpwl -lopenjpeg_JPWL +COMPILERFLAGS += -DUSE_JPWL +endif + +if with_libtiff +INCLUDES += @tiffincludes@ +USERLIBS += @tifflibs@ +endif + +if with_libpng +INCLUDES += @pngincludes@ +USERLIBS += @pnglibs@ +endif + +if with_liblcms2 +INCLUDES += @lcms2includes@ +USERLIBS += @lcms2libs@ +endif + +if with_liblcms1 +INCLUDES += @lcms1includes@ +USERLIBS += @lcms1libs@ +endif + +bin_PROGRAMS = j2k_to_image image_to_j2k j2k_dump + +CFLAGS = $(COMPILERFLAGS) $(INCLUDES) +LDADD = $(USERLIBS) ../libopenjpeg/libopenjpeg.la + +j2k_to_image_SOURCES = compat/getopt.c index.c convert.c j2k_to_image.c + +image_to_j2k_SOURCES = compat/getopt.c index.c convert.c image_to_j2k.c + +j2k_dump_SOURCES = compat/getopt.c index.c j2k_dump.c + +REPBIN=$(bin_PROGRAMS) + +all-local: + $(INSTALL) -d ../bin + $(INSTALL) $(bin_PROGRAMS) ../bin + @echo "" > .report.txt + @for f in ${REPBIN} ; do \ + echo "Installing: ${prefix}/bin/$$f" >> .report.txt ; \ + done diff --git a/codec/Makefile.in b/codec/Makefile.in new file mode 100644 index 00000000..5e629583 --- /dev/null +++ b/codec/Makefile.in @@ -0,0 +1,609 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +@with_libjpwl_TRUE@am__append_1 = -L../jpwl -lopenjpeg_JPWL +@with_libjpwl_TRUE@am__append_2 = -DUSE_JPWL +@with_libtiff_TRUE@am__append_3 = @tiffincludes@ +@with_libtiff_TRUE@am__append_4 = @tifflibs@ +@with_libpng_TRUE@am__append_5 = @pngincludes@ +@with_libpng_TRUE@am__append_6 = @pnglibs@ +@with_liblcms2_TRUE@am__append_7 = @lcms2includes@ +@with_liblcms2_TRUE@am__append_8 = @lcms2libs@ +@with_liblcms1_TRUE@am__append_9 = @lcms1includes@ +@with_liblcms1_TRUE@am__append_10 = @lcms1libs@ +bin_PROGRAMS = j2k_to_image$(EXEEXT) image_to_j2k$(EXEEXT) \ + j2k_dump$(EXEEXT) +subdir = codec +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/opj_config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am_image_to_j2k_OBJECTS = getopt.$(OBJEXT) index.$(OBJEXT) \ + convert.$(OBJEXT) image_to_j2k.$(OBJEXT) +image_to_j2k_OBJECTS = $(am_image_to_j2k_OBJECTS) +image_to_j2k_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +image_to_j2k_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + ../libopenjpeg/libopenjpeg.la +am_j2k_dump_OBJECTS = getopt.$(OBJEXT) index.$(OBJEXT) \ + j2k_dump.$(OBJEXT) +j2k_dump_OBJECTS = $(am_j2k_dump_OBJECTS) +j2k_dump_LDADD = $(LDADD) +j2k_dump_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + ../libopenjpeg/libopenjpeg.la +am_j2k_to_image_OBJECTS = getopt.$(OBJEXT) index.$(OBJEXT) \ + convert.$(OBJEXT) j2k_to_image.$(OBJEXT) +j2k_to_image_OBJECTS = $(am_j2k_to_image_OBJECTS) +j2k_to_image_LDADD = $(LDADD) +j2k_to_image_DEPENDENCIES = $(am__DEPENDENCIES_2) \ + ../libopenjpeg/libopenjpeg.la +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(image_to_j2k_SOURCES) $(j2k_dump_SOURCES) \ + $(j2k_to_image_SOURCES) +DIST_SOURCES = $(image_to_j2k_SOURCES) $(j2k_dump_SOURCES) \ + $(j2k_to_image_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_NR = @BUILD_NR@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = $(COMPILERFLAGS) $(INCLUDES) +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +JP3D_BUILD_NR = @JP3D_BUILD_NR@ +JP3D_MAJOR_NR = @JP3D_MAJOR_NR@ +JP3D_MINOR_NR = @JP3D_MINOR_NR@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDLIBS = @LDLIBS@ +LIBOBJS = @LIBOBJS@ +LIBPNG_CONFIG = @LIBPNG_CONFIG@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAJOR_NR = @MAJOR_NR@ +MAKEINFO = @MAKEINFO@ +MINOR_NR = @MINOR_NR@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG = @PKGCONFIG@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +doxy_dir = @doxy_dir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +jp3d_dir = @jp3d_dir@ +jpwl_dir = @jpwl_dir@ +lcms1includes = @lcms1includes@ +lcms1libs = @lcms1libs@ +lcms2includes = @lcms2includes@ +lcms2libs = @lcms2libs@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pngincludes = @pngincludes@ +pnglibs = @pnglibs@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tiffincludes = @tiffincludes@ +tifflibs = @tifflibs@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +with_doxygen = @with_doxygen@ +COMPILERFLAGS = -Wall $(am__append_2) +USERLIBS = -lm $(am__append_1) $(am__append_4) $(am__append_6) \ + $(am__append_8) $(am__append_10) +INCLUDES = -I.. -I. -I../libopenjpeg $(am__append_3) $(am__append_5) \ + $(am__append_7) $(am__append_9) +LDADD = $(USERLIBS) ../libopenjpeg/libopenjpeg.la +j2k_to_image_SOURCES = compat/getopt.c index.c convert.c j2k_to_image.c +image_to_j2k_SOURCES = compat/getopt.c index.c convert.c image_to_j2k.c +j2k_dump_SOURCES = compat/getopt.c index.c j2k_dump.c +REPBIN = $(bin_PROGRAMS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign codec/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign codec/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +image_to_j2k$(EXEEXT): $(image_to_j2k_OBJECTS) $(image_to_j2k_DEPENDENCIES) + @rm -f image_to_j2k$(EXEEXT) + $(LINK) $(image_to_j2k_OBJECTS) $(image_to_j2k_LDADD) $(LIBS) +j2k_dump$(EXEEXT): $(j2k_dump_OBJECTS) $(j2k_dump_DEPENDENCIES) + @rm -f j2k_dump$(EXEEXT) + $(LINK) $(j2k_dump_OBJECTS) $(j2k_dump_LDADD) $(LIBS) +j2k_to_image$(EXEEXT): $(j2k_to_image_OBJECTS) $(j2k_to_image_DEPENDENCIES) + @rm -f j2k_to_image$(EXEEXT) + $(LINK) $(j2k_to_image_OBJECTS) $(j2k_to_image_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convert.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/image_to_j2k.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/index.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/j2k_dump.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/j2k_to_image.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +getopt.o: compat/getopt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getopt.o -MD -MP -MF $(DEPDIR)/getopt.Tpo -c -o getopt.o `test -f 'compat/getopt.c' || echo '$(srcdir)/'`compat/getopt.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/getopt.Tpo $(DEPDIR)/getopt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='compat/getopt.c' object='getopt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getopt.o `test -f 'compat/getopt.c' || echo '$(srcdir)/'`compat/getopt.c + +getopt.obj: compat/getopt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getopt.obj -MD -MP -MF $(DEPDIR)/getopt.Tpo -c -o getopt.obj `if test -f 'compat/getopt.c'; then $(CYGPATH_W) 'compat/getopt.c'; else $(CYGPATH_W) '$(srcdir)/compat/getopt.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/getopt.Tpo $(DEPDIR)/getopt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='compat/getopt.c' object='getopt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getopt.obj `if test -f 'compat/getopt.c'; then $(CYGPATH_W) 'compat/getopt.c'; else $(CYGPATH_W) '$(srcdir)/compat/getopt.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) all-local +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am all-local check check-am clean \ + clean-binPROGRAMS clean-generic clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS + + +all-local: + $(INSTALL) -d ../bin + $(INSTALL) $(bin_PROGRAMS) ../bin + @echo "" > .report.txt + @for f in ${REPBIN} ; do \ + echo "Installing: ${prefix}/bin/$$f" >> .report.txt ; \ + done + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/codec/Makefile.nix b/codec/Makefile.nix new file mode 100644 index 00000000..f80094e3 --- /dev/null +++ b/codec/Makefile.nix @@ -0,0 +1,66 @@ +#codec Makefile +include ../config.nix + +CFLAGS = -Wall + +INSTALL_BIN = $(prefix)/bin + +INCLUDE = -I.. -I. -I../libopenjpeg +USERLIBS = -lm + +ifeq ($(WITH_TIFF),yes) +INCLUDE += $(TIFF_INCLUDE) +USERLIBS += $(TIFF_LIB) +endif + +ifeq ($(WITH_JPWL),yes) +USERLIBS += ../jpwl/libopenjpeg_JPWL.a +CFLAGS += -DUSE_JPWL +endif + +ifeq ($(WITH_PNG),yes) +INCLUDE += $(PNG_INCLUDE) +USERLIBS += $(PNG_LIB) +endif + +ifeq ($(WITH_LCMS2),yes) +INCLUDE += $(LCMS2_INCLUDE) +USERLIBS += $(LCMS2_LIB) +endif + +ifeq ($(WITH_LCMS1),yes) +INCLUDE += $(LCMS1_INCLUDE) +USERLIBS += $(LCMS1_LIB) +endif + +CFLAGS += $(INCLUDE) -lstdc++ # -g -p -pg + +all: j2k_to_image image_to_j2k j2k_dump + install -d ../bin + install j2k_to_image image_to_j2k j2k_dump ../bin + +j2k_to_image: j2k_to_image.c ../libopenjpeg.a + $(CC) $(CFLAGS) compat/getopt.c index.c convert.c j2k_to_image.c \ + -o j2k_to_image ../libopenjpeg.a $(USERLIBS) + +image_to_j2k: image_to_j2k.c ../libopenjpeg.a + $(CC) $(CFLAGS) compat/getopt.c index.c convert.c image_to_j2k.c \ + -o image_to_j2k ../libopenjpeg.a $(USERLIBS) + +j2k_dump: j2k_dump.c ../libopenjpeg.a + $(CC) $(CFLAGS) compat/getopt.c index.c j2k_dump.c \ + -o j2k_dump ../libopenjpeg.a $(USERLIBS) + +clean: + rm -f j2k_to_image image_to_j2k j2k_dump + +install: all + install -d $(DESTDIR)$(INSTALL_BIN) + install -m 755 -o root -g root j2k_to_image $(DESTDIR)$(INSTALL_BIN) + install -m 755 -o root -g root image_to_j2k $(DESTDIR)$(INSTALL_BIN) + install -m 755 -o root -g root j2k_dump $(DESTDIR)$(INSTALL_BIN) + +uninstall: + rm -f $(DESTDIR)$(INSTALL_BIN)/j2k_to_image + rm -f $(DESTDIR)$(INSTALL_BIN)/image_to_j2k + rm -f $(DESTDIR)$(INSTALL_BIN)/j2k_dump diff --git a/codec/README b/codec/README new file mode 100644 index 00000000..80049980 --- /dev/null +++ b/codec/README @@ -0,0 +1,8 @@ +Simple codec compilation +------------------------ +Once you've built the library, you might want to test it with a basic codec. To do this, go to the codec directory and either use the provided Makefile or use one of the following commands to build an encoder and decoder respectively: + +gcc index.c convert.c image_to_j2k.c -o image_to_j2k -lopenjpeg -I ../libopenjpeg/ -lm -ltiff +gcc index.c convert.c j2k_to_image.c -o j2k_to_image -lopenjpeg -I ../libopenjpeg/ -lm -ltiff + +You should add '-L..' to those lines if you did not use the 'install' target when building the library.
\ No newline at end of file diff --git a/codec/convert.c b/codec/convert.c index 63707a09..3ab3e7ab 100644 --- a/codec/convert.c +++ b/codec/convert.c @@ -29,16 +29,28 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include <opj_config.h> +#define TEST_WITH_GAMMA #include <stdio.h> #include <stdlib.h> #include <string.h> + +#ifdef HAVE_LIBTIFF #ifdef WIN32 #include "tiffio.h" -#include "png.h" #else #include <tiffio.h> +#endif /* WIN32 */ +#endif /* HAVE_LIBTIFF */ + +#ifdef HAVE_LIBPNG +#ifdef WIN32 +#include "png.h" +#else #include <png.h> #endif /* WIN32 */ +#endif /* HAVE_LIBPNG */ + #include "openjpeg.h" #include "convert.h" @@ -84,28 +96,29 @@ static int int_ceildiv(int a, int b) { #pragma pack(push,1) // Pack structure byte aligned typedef struct tga_header { - uint8 id_length; /* Image id field length */ - uint8 colour_map_type; /* Colour map type */ - uint8 image_type; /* Image type */ + unsigned char id_length; /* Image id field length */ + unsigned char colour_map_type; /* Colour map type */ + unsigned char image_type; /* Image type */ /* ** Colour map specification */ - uint16 colour_map_index; /* First entry index */ - uint16 colour_map_length; /* Colour map length */ - uint8 colour_map_entry_size; /* Colour map entry size */ + unsigned short colour_map_index; /* First entry index */ + unsigned short colour_map_length; /* Colour map length */ + unsigned char colour_map_entry_size; /* Colour map entry size */ /* ** Image specification */ - uint16 x_origin; /* x origin of image */ - uint16 y_origin; /* u origin of image */ - uint16 image_width; /* Image width */ - uint16 image_height; /* Image height */ - uint8 pixel_depth; /* Pixel depth */ - uint8 image_desc; /* Image descriptor */ + unsigned short x_origin; /* x origin of image */ + unsigned short y_origin; /* u origin of image */ + unsigned short image_width; /* Image width */ + unsigned short image_height; /* Image height */ + unsigned char pixel_depth; /* Pixel depth */ + unsigned char image_desc; /* Image descriptor */ } tga_header; #pragma pack(pop) // Return to normal structure packing alignment. -int tga_readheader(FILE *fp, uint32 *bits_per_pixel, uint32 *width, uint32 *height, int *flip_image) +int tga_readheader(FILE *fp, unsigned int *bits_per_pixel, + unsigned int *width, unsigned int *height, int *flip_image) { int palette_size; tga_header tga ; @@ -114,7 +127,7 @@ int tga_readheader(FILE *fp, uint32 *bits_per_pixel, uint32 *width, uint32 *heig return 0; // Read TGA header - fread((uint8*)&tga, sizeof(tga_header), 1, fp); + fread((unsigned char*)&tga, sizeof(tga_header), 1, fp); *bits_per_pixel = tga.pixel_depth; @@ -124,7 +137,7 @@ int tga_readheader(FILE *fp, uint32 *bits_per_pixel, uint32 *width, uint32 *heig // Ignore tga identifier, if present ... if (tga.id_length) { - uint8 *id = (uint8 *) malloc(tga.id_length); + unsigned char *id = (unsigned char *) malloc(tga.id_length); fread(id, tga.id_length, 1, fp); free(id); } @@ -151,7 +164,8 @@ int tga_readheader(FILE *fp, uint32 *bits_per_pixel, uint32 *width, uint32 *heig return 1; } -int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height, bool flip_image) +int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height, + bool flip_image) { tga_header tga; @@ -170,7 +184,7 @@ int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height, bool fl tga.image_desc |= 32; // Write TGA header - fwrite((uint8*)&tga, sizeof(tga_header), 1, fp); + fwrite((unsigned char*)&tga, sizeof(tga_header), 1, fp); return 1; } @@ -178,8 +192,8 @@ int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height, bool fl opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) { FILE *f; opj_image_t *image; - uint32 image_width, image_height, pixel_bit_depth; - uint32 x, y; + unsigned int image_width, image_height, pixel_bit_depth; + unsigned int x, y; int flip_image=0; opj_image_cmptparm_t cmptparm[4]; /* maximum 4 components */ int numcomps; @@ -256,7 +270,7 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) { { for (x=0;x<image_width;x++) { - uint8 r,g,b; + unsigned char r,g,b; fread(&b, 1, 1, f); fread(&g, 1, 1, f); fread(&r, 1, 1, f); @@ -271,7 +285,7 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) { { for (x=0;x<image_width;x++) { - uint8 r,g,b,a; + unsigned char r,g,b,a; fread(&b, 1, 1, f); fread(&g, 1, 1, f); fread(&r, 1, 1, f); @@ -295,9 +309,9 @@ int imagetotga(opj_image_t * image, const char *outfile) { int width, height, bpp, x, y; bool write_alpha; int i; - uint32 alpha_channel; + unsigned int alpha_channel; float r,g,b,a; - uint8 value; + unsigned char value; float scale; FILE *fdest; @@ -332,7 +346,7 @@ int imagetotga(opj_image_t * image, const char *outfile) { scale = 255.0f / (float)((1<<image->comps[0].prec)-1); for (y=0; y < height; y++) { - uint32 index=y*width; + unsigned int index=y*width; for (x=0; x < width; x++, index++) { r = (float)(image->comps[0].data[index]); @@ -347,18 +361,18 @@ int imagetotga(opj_image_t * image, const char *outfile) { } // TGA format writes BGR ... - value = (uint8)(b*scale); + value = (unsigned char)(b*scale); fwrite(&value,1,1,fdest); - value = (uint8)(g*scale); + value = (unsigned char)(g*scale); fwrite(&value,1,1,fdest); - value = (uint8)(r*scale); + value = (unsigned char)(r*scale); fwrite(&value,1,1,fdest); if (write_alpha) { a = (float)(image->comps[alpha_channel].data[index]); - value = (uint8)(a*scale); + value = (unsigned char)(a*scale); fwrite(&value,1,1,fdest); } } @@ -1400,6 +1414,7 @@ int imagetopnm(opj_image_t * image, const char *outfile) { return 0; } +#ifdef HAVE_LIBTIFF /* -->> -->> -->> -->> TIFF IMAGE FORMAT @@ -1944,6 +1959,8 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters) return image; } +#endif /* HAVE_LIBTIFF */ + /* -->> -->> -->> -->> RAW IMAGE FORMAT @@ -2163,6 +2180,12 @@ int imagetoraw(opj_image_t * image, const char *outfile) return 0; } +#ifdef HAVE_LIBPNG + +#define PNG_MAGIC "\x89PNG\x0d\x0a\x1a\x0a" +#define MAGIC_SIZE 8 +/* PNG allows bits per sample: 1, 2, 4, 8, 16 */ + opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params) #ifdef WIN32 { @@ -2171,169 +2194,182 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params) } #else { - png_bytep row; - png_structp png; - png_infop info; - double gamma, display_exponent; - int bit_depth, interlace_type, compression_type, filter_type; - int unit, pass, nr_passes; - png_uint_32 resx, resy; - unsigned int i, max, src_w; - png_uint_32 width, height; - int color_type, has_alpha; - unsigned char *png_buf, *s; - FILE *reader; + png_structp png; + png_infop info; + double gamma, display_exponent; + int bit_depth, interlace_type,compression_type, filter_type; + int unit; + png_uint_32 resx, resy; + unsigned int i, j; + png_uint_32 width, height; + int color_type, has_alpha, is16; + unsigned char *s; + FILE *reader; + unsigned char **rows; /* j2k: */ - opj_image_t *image; - opj_image_cmptparm_t cmptparm[4]; - int sub_dx, sub_dy; - unsigned int nr_comp; - int *r, *g, *b, *a; - - if ((reader = fopen(read_idf, "rb")) == NULL) { - fprintf(stderr, "pngtoimage: can not open %s\n", read_idf); + opj_image_t *image; + opj_image_cmptparm_t cmptparm[4]; + int sub_dx, sub_dy; + unsigned int nr_comp; + int *r, *g, *b, *a; + unsigned char sigbuf[8]; + + if((reader = fopen(read_idf, "rb")) == NULL) + { + fprintf(stderr,"pngtoimage: can not open %s\n",read_idf); return NULL; - } - nr_passes = 0; - png_buf = NULL; + } + image = NULL; png = NULL; rows = NULL; + if(fread(sigbuf, 1, MAGIC_SIZE, reader) != MAGIC_SIZE + || memcmp(sigbuf, PNG_MAGIC, MAGIC_SIZE) != 0) + { + fprintf(stderr,"pngtoimage: %s is no valid PNG file\n",read_idf); + goto fin; + } /* libpng-VERSION/example.c: * PC : screen_gamma = 2.2; * Mac: screen_gamma = 1.7 or 1.0; */ - display_exponent = 2.2; + display_exponent = 2.2; - if ((png = png_create_read_struct(PNG_LIBPNG_VER_STRING, - NULL, NULL, NULL)) == NULL) - goto fin; - if ((info = png_create_info_struct(png)) == NULL) - goto fin; + if((png = png_create_read_struct(PNG_LIBPNG_VER_STRING, + NULL, NULL, NULL)) == NULL) + goto fin; + if((info = png_create_info_struct(png)) == NULL) + goto fin; - if (setjmp(png_jmpbuf(png))) - goto fin; + if(setjmp(png_jmpbuf(png))) + goto fin; - png_init_io(png, reader); - png_read_info(png, info); + png_init_io(png, reader); + png_set_sig_bytes(png, MAGIC_SIZE); - png_get_IHDR(png, info, &width, &height, - &bit_depth, &color_type, &interlace_type, - &compression_type, &filter_type); + png_read_info(png, info); - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_expand(png); - else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand(png); + if(png_get_IHDR(png, info, &width, &height, + &bit_depth, &color_type, &interlace_type, + &compression_type, &filter_type) == 0) + goto fin; - if (png_get_valid(png, info, PNG_INFO_tRNS)) - png_set_expand(png); +/* png_set_expand(): + * expand paletted images to RGB, expand grayscale images of + * less than 8-bit depth to 8-bit depth, and expand tRNS chunks + * to alpha channels. +*/ + if(color_type == PNG_COLOR_TYPE_PALETTE) + png_set_expand(png); + else + if(color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) + png_set_expand(png); + + if(png_get_valid(png, info, PNG_INFO_tRNS)) + png_set_expand(png); - if (bit_depth == 16) - png_set_strip_16(png); + is16 = (bit_depth == 16); /* GRAY => RGB; GRAY_ALPHA => RGBA */ - if (color_type == PNG_COLOR_TYPE_GRAY - || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + if(color_type == PNG_COLOR_TYPE_GRAY + || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { png_set_gray_to_rgb(png); - color_type = - (color_type == PNG_COLOR_TYPE_GRAY ? PNG_COLOR_TYPE_RGB : - PNG_COLOR_TYPE_RGB_ALPHA); - } - if (!png_get_gAMA(png, info, &gamma)) - gamma = 0.45455; + color_type = + (color_type == PNG_COLOR_TYPE_GRAY? PNG_COLOR_TYPE_RGB: + PNG_COLOR_TYPE_RGB_ALPHA); + } + if( !png_get_gAMA(png, info, &gamma)) + gamma = 0.45455; - png_set_gamma(png, display_exponent, gamma); + png_set_gamma(png, display_exponent, gamma); - nr_passes = png_set_interlace_handling(png); + png_read_update_info(png, info); - png_read_update_info(png, info); + png_get_pHYs(png, info, &resx, &resy, &unit); - png_get_pHYs(png, info, &resx, &resy, &unit); + color_type = png_get_color_type(png, info); - color_type = png_get_color_type(png, info); + has_alpha = (color_type == PNG_COLOR_TYPE_RGB_ALPHA); - has_alpha = (color_type == PNG_COLOR_TYPE_RGB_ALPHA); + nr_comp = 3 + has_alpha; - if (has_alpha) - nr_comp = 4; - else - nr_comp = 3; + bit_depth = png_get_bit_depth(png, info); - src_w = width * nr_comp; - png_buf = (unsigned char *) malloc(src_w * height); + rows = (unsigned char**)calloc(height+1, sizeof(unsigned char*)); + for(i = 0; i < height; ++i) + rows[i] = (unsigned char*)malloc(png_get_rowbytes(png,info)); - if (nr_passes == 0) - nr_passes = 1; + png_read_image(png, rows); - for (pass = 0; pass < nr_passes; pass++) { - s = png_buf; + memset(&cmptparm, 0, 4 * sizeof(opj_image_cmptparm_t)); - for (i = 0; i < height; i++) { -/* libpng.3: - * If you want the "sparkle" effect, just call png_read_rows() as - * normal, with the third parameter NULL. -*/ - png_read_rows(png, &s, NULL, 1); + sub_dx = params->subsampling_dx; sub_dy = params->subsampling_dy; - s += src_w; - } - } - memset(&cmptparm, 0, 4 * sizeof(opj_image_cmptparm_t)); - - sub_dx = params->subsampling_dx; - sub_dy = params->subsampling_dy; - - for (i = 0; i < nr_comp; ++i) { - cmptparm[i].prec = 8; - cmptparm[i].bpp = 8; + for(i = 0; i < nr_comp; ++i) + { + cmptparm[i].prec = bit_depth; +/* bits_per_pixel: 8 or 16 */ + cmptparm[i].bpp = bit_depth; cmptparm[i].sgnd = 0; cmptparm[i].dx = sub_dx; cmptparm[i].dy = sub_dy; cmptparm[i].w = width; cmptparm[i].h = height; - } + } - image = opj_image_create(nr_comp, &cmptparm[0], CLRSPC_SRGB); + image = opj_image_create(nr_comp, &cmptparm[0], CLRSPC_SRGB); - if (image == NULL) - goto fin; + if(image == NULL) goto fin; image->x0 = params->image_offset_x0; image->y0 = params->image_offset_y0; - image->x1 = - params->image_offset_x0 + (width - 1) * sub_dx + 1 + image->x0; - image->y1 = - params->image_offset_y0 + (height - 1) * sub_dy + 1 + image->y0; + image->x1 = image->x0 + (width - 1) * sub_dx + 1 + image->x0; + image->y1 = image->y0 + (height - 1) * sub_dy + 1 + image->y0; - r = image->comps[0].data; - g = image->comps[1].data; - b = image->comps[2].data; - a = image->comps[3].data; - s = png_buf; + r = image->comps[0].data; + g = image->comps[1].data; + b = image->comps[2].data; + a = image->comps[3].data; - max = width * height; + for(i = 0; i < height; ++i) + { + s = rows[i]; - for (i = 0; i < max; ++i) { - *r++ = *s++; - *g++ = *s++; - *b++ = *s++; + for(j = 0; j < width; ++j) + { + if(is16) + { + *r++ = s[0]<<8|s[1]; s += 2; - if (has_alpha) - *a++ = *s++; - } + *g++ = s[0]<<8|s[1]; s += 2; + + *b++ = s[0]<<8|s[1]; s += 2; + + if(has_alpha) { *a++ = s[0]<<8|s[1]; s += 2; } - fin: - if (png) - png_destroy_read_struct(&png, &info, NULL); - if (png_buf) - free(png_buf); + continue; + } + *r++ = *s++; *g++ = *s++; *b++ = *s++; - fclose(reader); + if(has_alpha) *a++ = *s++; + } + } +fin: + if(rows) + { + for(i = 0; i < height; ++i) + free(rows[i]); + free(rows); + } + if(png) + png_destroy_read_struct(&png, &info, NULL); - return image; + fclose(reader); -} /* pngtoimage() */ -#endif + return image; + +}/* pngtoimage() */ +#endif /* WIN32 */ int imagetopng(opj_image_t * image, const char *write_idf) #ifdef WIN32 @@ -2343,23 +2379,32 @@ int imagetopng(opj_image_t * image, const char *write_idf) } #else { - FILE *writer; - png_structp png_ptr; - png_infop info_ptr; - int *rs, *gs, *bs, *as; - unsigned char *row_buf, *d; - int fails, mono, graya, rgb, rgba; - int width, height, nr_colors, color_type; - int bit_depth, adjust, x, y; - png_color_8 sig_bit; - - writer = fopen(write_idf, "wb"); - - if (writer == NULL) + FILE *writer; + png_structp png; + png_infop info; + int *red, *green, *blue, *alpha; + unsigned char *row_buf, *d; + int has_alpha, width, height, nr_comp, color_type; + int adjust, x, y, fails, is16; + int opj_prec, prec; + unsigned short mask; + png_color_8 sig_bit; + + prec = opj_prec = image->comps[0].prec; + + if(prec > 8) prec = 16; + + if(prec != 1 && prec != 2 && prec != 4 && prec != 8 && prec != 16) + { + fprintf(stderr,"imagetopng: can not create %s" + "\n\twrong bit_depth %d\n", write_idf, prec); return 1; + } + writer = fopen(write_idf, "wb"); + + if(writer == NULL) return 1; - info_ptr = NULL; - fails = 1; + info = NULL; fails = 1; has_alpha = 0; /* Create and initialize the png_struct with the desired error handler * functions. If you want to use the default stderr and longjump method, @@ -2367,29 +2412,26 @@ int imagetopng(opj_image_t * image, const char *write_idf) * the library version is compatible with the one used at compile time, * in case we are using dynamically linked libraries. REQUIRED. */ - png_ptr = - png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + png = png_create_write_struct(PNG_LIBPNG_VER_STRING, + NULL, NULL, NULL); /*png_voidp user_error_ptr, user_error_fn, user_warning_fn); */ - if (png_ptr == NULL) - goto fin; + if(png == NULL) goto fin; /* Allocate/initialize the image information data. REQUIRED */ - info_ptr = png_create_info_struct(png_ptr); + info = png_create_info_struct(png); - if (info_ptr == NULL) - goto fin; + if(info == NULL) goto fin; /* Set error handling. REQUIRED if you are not supplying your own * error handling functions in the png_create_write_struct() call. */ - if (setjmp(png_jmpbuf(png_ptr))) - goto fin; + if(setjmp(png_jmpbuf(png))) goto fin; /* I/O initialization functions is REQUIRED */ - png_init_io(png_ptr, writer); + png_init_io(png, writer); /* Set the image information here. Width and height are up to 2^31, * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on @@ -2400,119 +2442,244 @@ int imagetopng(opj_image_t * image, const char *write_idf) * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. * REQUIRED */ - png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); - - mono = graya = rgb = rgba = adjust = 0; - - nr_colors = image->numcomps; + png_set_compression_level(png, Z_BEST_COMPRESSION); + + adjust = 0; + if(image->comps[0].sgnd) adjust = 1 << (opj_prec - 1); + + if(prec == 8) mask = 0x00ff; + else + if(prec == 4) mask = 0x000f; + else + if(prec == 2) mask = 0x0003; + else + if(prec == 1) mask = 0x0001; + else + if(opj_prec == 12) mask = 0x0fff; + else + mask = 0xffff; + + nr_comp = image->numcomps; + + if(nr_comp >= 3 + && image->comps[0].dx == image->comps[1].dx + && image->comps[1].dx == image->comps[2].dx + && image->comps[0].dy == image->comps[1].dy + && image->comps[1].dy == image->comps[2].dy + && image->comps[0].prec == image->comps[1].prec + && image->comps[1].prec == image->comps[2].prec) + { + has_alpha = (nr_comp > 3); + + is16 = (prec == 16); + width = image->comps[0].w; height = image->comps[0].h; - rs = image->comps[0].data; - if (nr_colors == 2) { - graya = 1; - color_type = PNG_COLOR_TYPE_GRAY_ALPHA; - sig_bit.gray = image->comps[0].prec; - bit_depth = image->comps[0].prec; - as = image->comps[1].data; - } else if (nr_colors == 3) { - rgb = 1; - color_type = PNG_COLOR_TYPE_RGB; - sig_bit.red = image->comps[0].prec; - sig_bit.green = image->comps[1].prec; - sig_bit.blue = image->comps[2].prec; - bit_depth = image->comps[0].prec; - gs = image->comps[1].data; - bs = image->comps[2].data; - if (image->comps[0].sgnd) - adjust = 1 << (image->comps[0].prec - 1); - } else if (nr_colors == 4) { - rgb = rgba = 1; + red = image->comps[0].data; + green = image->comps[1].data; + blue = image->comps[2].data; + + sig_bit.red = sig_bit.green = sig_bit.blue = prec; + + if(has_alpha) + { + sig_bit.alpha = prec; + alpha = image->comps[3].data; color_type = PNG_COLOR_TYPE_RGB_ALPHA; - sig_bit.red = image->comps[0].prec; - sig_bit.green = image->comps[1].prec; - sig_bit.blue = image->comps[2].prec; - sig_bit.alpha = image->comps[3].prec; - bit_depth = image->comps[0].prec; - gs = image->comps[1].data; - bs = image->comps[2].data; - as = image->comps[3].data; - if (image->comps[0].sgnd) - adjust = 1 << (image->comps[0].prec - 1); - } else { - mono = 1; - color_type = PNG_COLOR_TYPE_GRAY; - sig_bit.gray = image->comps[0].prec; - bit_depth = image->comps[0].prec; - } - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - color_type, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - -#ifdef HIDDEN_CODE -/* Optional gamma chunk is strongly suggested if you have any guess - * as to the correct gamma of the image. + } + else + { + sig_bit.alpha = 0; alpha = NULL; + color_type = PNG_COLOR_TYPE_RGB; + } + png_set_sBIT(png, info, &sig_bit); + + png_set_IHDR(png, info, width, height, prec, + color_type, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + +/*=============================*/ + png_write_info(png, info); +/*=============================*/ + +/* Shift the pixels up to a legal bit depth and fill in + * as appropriate to correctly scale the image. */ + if(opj_prec > 8 && opj_prec < 16) + { + png_set_shift(png, &sig_bit); + } + if(opj_prec < 8) + { + png_set_packing(png); + } + + row_buf = (unsigned char*)malloc(width * nr_comp * 2); + + for(y = 0; y < height; ++y) + { + d = row_buf; - if (gamma > 0.0) { - png_set_gAMA(png_ptr, info_ptr, gamma); - } -#endif /* HIDDEN_CODE */ -#ifdef HIDDEN_CODE - if (have_bg) { - png_color_16 background; + for(x = 0; x < width; ++x) + { + if(is16) + { +/* Network byte order */ + unsigned short v; + + v = (unsigned short)((*red + adjust) & mask); ++red; + *d++ = (unsigned char)(v>>8); *d++ = (unsigned char)v; + v = (unsigned short)((*green + adjust) & mask); ++green; + *d++ = (unsigned char)(v>>8); *d++ = (unsigned char)v; + v = (unsigned short)((*blue + adjust) & mask); ++blue; + *d++ = (unsigned char)(v>>8); *d++ = (unsigned char)v; + + if(has_alpha) + { + v = (unsigned short)((*alpha + adjust) & mask); ++alpha; + *d++ = (unsigned char)(v>>8); *d++ = (unsigned char)v; + } + continue; + } + *d++ = (unsigned char)((*red + adjust) & mask); ++red; + *d++ = (unsigned char)((*green + adjust) & mask); ++green; + *d++ = (unsigned char)((*blue + adjust) & mask); ++blue; + + if(has_alpha) + { + *d++ = (unsigned char)((*alpha + adjust) & mask); ++alpha; + } + } /* for(x) */ + + png_write_row(png, row_buf); + + } /* for(y) */ + free(row_buf); + + }/* nr_comp >= 3 */ + else + if(nr_comp == 1 /* GRAY */ + || ( nr_comp == 2 /* GRAY_ALPHA */ + && image->comps[0].dx == image->comps[1].dx + && image->comps[0].dy == image->comps[1].dy + && image->comps[0].prec == image->comps[1].prec)) + { + red = image->comps[0].data; - background.red = bg_red; - background.green = bg_green; - background.blue = bg_blue; + sig_bit.gray = prec; + sig_bit.red = sig_bit.green = sig_bit.blue = sig_bit.alpha = 0; + alpha = NULL; + color_type = PNG_COLOR_TYPE_GRAY; - png_set_bKGD(png_ptr, info_ptr, &background); - } -#endif /* HIDDEN_CODE */ - png_write_info(png_ptr, info_ptr); + if(nr_comp == 2) + { + has_alpha = 1; sig_bit.alpha = prec; + alpha = image->comps[1].data; + color_type = PNG_COLOR_TYPE_GRAY_ALPHA; + } + width = image->comps[0].w; + height = image->comps[0].h; - png_set_packing(png_ptr); + png_set_IHDR(png, info, width, height, sig_bit.gray, + color_type, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - row_buf = (unsigned char *) malloc(width * nr_colors); + png_set_sBIT(png, info, &sig_bit); +#ifdef TEST_WITH_GAMMA + png_set_gAMA(png, info, 1.0); +#endif +/*=============================*/ + png_write_info(png, info); +/*=============================*/ - for (y = 0; y < height; ++y) { +/* Shift the pixels up to a legal bit depth and fill in + * as appropriate to correctly scale the image. +*/ + if(opj_prec > 8 && opj_prec < 16) + { + png_set_shift(png, &sig_bit); + } + if(opj_prec < 8) + { + png_set_packing(png); + } + + if(prec > 8) + { +/* Network byte order */ + unsigned short v; + + row_buf = (unsigned char*) + malloc(width * nr_comp * sizeof(unsigned short)); + + if(opj_prec == 12) mask = 0x0fff; + + for(y = 0; y < height; ++y) + { d = row_buf; - for (x = 0; x < width; ++x) { - if (mono) { - *d++ = (unsigned char) *rs++; - } - if (graya) { - *d++ = (unsigned char) *rs++; - *d++ = (unsigned char) *as++; - } else if (rgb) { - *d++ = (unsigned char) (*rs++ + adjust); - *d++ = (unsigned char) (*gs++ + adjust); - *d++ = (unsigned char) (*bs++ + adjust); + for(x = 0; x < width; ++x) + { + v = (unsigned short)((*red + adjust) & mask); ++red; + *d++ = (unsigned char)(v>>8); *d++ = (unsigned char)(v & 0xff); + + if(has_alpha) + { + v = (unsigned short)((*alpha + adjust) & mask); ++alpha; + *d++ = (unsigned char)(v>>8); *d++ = (unsigned char)(v & 0xff); + } + }/* for(x) */ + png_write_row(png, row_buf); + + } /* for(y) */ + free(row_buf); + } + else /* prec <= 8 */ + { + row_buf = (unsigned char*)calloc(width, nr_comp * 2); + + for(y = 0; y < height; ++y) + { + d = row_buf; - if (rgba) - *d++ = (unsigned char) (*as++ + adjust); - } - } /* for(x) */ + for(x = 0; x < width; ++x) + { + *d++ = (unsigned char)((*red + adjust) & mask); ++red; - png_write_row(png_ptr, row_buf); + if(has_alpha) + { + *d++ = (unsigned char)((*alpha + adjust) & mask); ++alpha; + } + }/* for(x) */ - } /* for(y) */ + png_write_row(png, row_buf); - png_write_end(png_ptr, info_ptr); + } /* for(y) */ + free(row_buf); + } + } + else + { + fprintf(stderr,"imagetopng: can not create %s\n",write_idf); + goto fin; + } + png_write_end(png, info); + + fails = 0; - fails = 0; +fin: - fin: + if(png) + { + png_destroy_write_struct(&png, &info); + } + fclose(writer); - if (png_ptr) { - png_destroy_write_struct(&png_ptr, &info_ptr); - } - fclose(writer); + return fails; +}/* imagetopng() */ +#endif /* WIN32 */ +#endif /* HAVE_LIBPNG */ - return fails; -} -#endif diff --git a/codec/image_to_j2k.c b/codec/image_to_j2k.c index 7acaed07..c9fcba54 100644 --- a/codec/image_to_j2k.c +++ b/codec/image_to_j2k.c @@ -29,6 +29,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include <opj_config.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -37,7 +38,11 @@ #include "openjpeg.h" #include "compat/getopt.h" #include "convert.h" -#include "dirent.h" +#ifdef WIN32 +#include "windirent.h" +#else +#include <dirent.h> +#endif /* WIN32 */ #include "index.h" #ifndef WIN32 @@ -1619,7 +1624,7 @@ int main(int argc, char **argv) { return 1; } break; - +#ifdef HAVE_LIBTIFF case TIF_DFMT: image = tiftoimage(parameters.infile, ¶meters); if (!image) { @@ -1627,7 +1632,7 @@ int main(int argc, char **argv) { return 1; } break; - +#endif /* HAVE_LIBTIFF */ case RAW_DFMT: image = rawtoimage(parameters.infile, ¶meters, &raw_cp); if (!image) { @@ -1643,7 +1648,7 @@ int main(int argc, char **argv) { return 1; } break; - +#ifdef HAVE_LIBPNG case PNG_DFMT: image = pngtoimage(parameters.infile, ¶meters); if (!image) { @@ -1651,7 +1656,16 @@ int main(int argc, char **argv) { return 1; } break; +#endif /* HAVE_LIBPNG */ } +/* Can happen if input file is TIFF or PNG + * and HAVE_LIBTIF or HAVE_LIBPNG is undefined +*/ + if( !image) + { + fprintf(stderr, "Unable to load file: got no image\n"); + return 1; + } /* Decide if MCT should be used */ parameters.tcp_mct = image->numcomps == 3 ? 1 : 0; diff --git a/codec/j2k_dump.c b/codec/j2k_dump.c index 5042f47a..35172a0e 100644 --- a/codec/j2k_dump.c +++ b/codec/j2k_dump.c @@ -1,3 +1,4 @@ +#include <opj_config.h> /* * Copyright (c) 20010, Mathieu Malaterre, GDCM * All rights reserved. @@ -30,11 +31,15 @@ #include <math.h> #include "openjpeg.h" -#include "j2k.h" -#include "jp2.h" +#include "../libopenjpeg/j2k.h" +#include "../libopenjpeg/jp2.h" #include "compat/getopt.h" #include "convert.h" -#include "dirent.h" +#ifdef WIN32 +#include "windirent.h" +#else +#include <dirent.h> +#endif /* WIN32 */ #include "index.h" #ifndef WIN32 diff --git a/codec/j2k_to_image.c b/codec/j2k_to_image.c index 3b1915c7..2e93fcdc 100644 --- a/codec/j2k_to_image.c +++ b/codec/j2k_to_image.c @@ -29,6 +29,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include <opj_config.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -37,7 +38,11 @@ #include "openjpeg.h" #include "compat/getopt.h" #include "convert.h" -#include "dirent.h" +#ifdef WIN32 +#include "windirent.h" +#else +#include <dirent.h> +#endif /* WIN32 */ #include "index.h" #ifndef WIN32 @@ -764,7 +769,7 @@ int main(int argc, char **argv) { fprintf(stdout,"Generated Outfile %s\n",parameters.outfile); } break; - +#ifdef HAVE_LIBTIFF case TIF_DFMT: /* TIFF */ if(imagetotif(image, parameters.outfile)){ fprintf(stdout,"Outfile %s not generated\n",parameters.outfile); @@ -773,7 +778,7 @@ int main(int argc, char **argv) { fprintf(stdout,"Generated Outfile %s\n",parameters.outfile); } break; - +#endif /* HAVE_LIBTIFF */ case RAW_DFMT: /* RAW */ if(imagetoraw(image, parameters.outfile)){ fprintf(stdout,"Error generating raw file. Outfile %s not generated\n",parameters.outfile); @@ -791,7 +796,7 @@ int main(int argc, char **argv) { fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile); } break; - +#ifdef HAVE_LIBPNG case PNG_DFMT: /* PNG */ if(imagetopng(image, parameters.outfile)){ fprintf(stdout,"Error generating png file. Outfile %s not generated\n",parameters.outfile); @@ -800,6 +805,12 @@ int main(int argc, char **argv) { fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile); } break; +#endif /* HAVE_LIBPNG */ +/* Can happen if output file is TIFF or PNG + * and HAVE_LIBTIF or HAVE_LIBPNG is undefined +*/ + default: + fprintf(stderr,"Outfile %s not generated\n",parameters.outfile); } /* free remaining structures */ diff --git a/codec/dirent.h b/codec/windirent.h index 037569df..037569df 100644 --- a/codec/dirent.h +++ b/codec/windirent.h |
