Skip to content

Commit

Permalink
Start implementation of input from JPEG file
Browse files Browse the repository at this point in the history
This is work in progress and still not functional.
It should at least support `opj_compress -i image.jpg -o image.jp2`.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Feb 29, 2024
1 parent ddd1c33 commit 836944d
Show file tree
Hide file tree
Showing 7 changed files with 646 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/bin/common/format_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#define JP2_CFMT 1
#define JPT_CFMT 2

#define JPEG_DFMT 9
#define PXM_DFMT 10
#define PGX_DFMT 11
#define BMP_DFMT 12
Expand Down
2 changes: 2 additions & 0 deletions src/bin/common/opj_apps_config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

/* create opj_apps_config.h for CMake */

#cmakedefine OPJ_HAVE_LIBJPEG @HAVE_LIBJPEG@
#cmakedefine OPJ_HAVE_JPEG_H @HAVE_JPEG_H@
#cmakedefine OPJ_HAVE_LIBPNG @HAVE_LIBPNG@
#cmakedefine OPJ_HAVE_PNG_H @HAVE_PNG_H@
#cmakedefine OPJ_HAVE_LIBTIFF @HAVE_LIBTIFF@
Expand Down
6 changes: 5 additions & 1 deletion src/bin/jp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ set(common_SRCS
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_string.h
)

if(OPJ_HAVE_LIBJPEG)
list(APPEND common_SRCS convertjpeg.c)
endif()
if(OPJ_HAVE_LIBTIFF)
list(APPEND common_SRCS converttif.c)
endif()
Expand All @@ -29,6 +32,7 @@ include_directories(
${OPENJPEG_SOURCE_DIR}/src/bin/common
${LCMS_INCLUDE_DIRNAME}
${Z_INCLUDE_DIRNAME}
${JPEG_INCLUDE_DIRNAME}
${PNG_INCLUDE_DIRNAME}
${TIFF_INCLUDE_DIRNAME}
)
Expand All @@ -46,7 +50,7 @@ foreach(exe opj_decompress opj_compress opj_dump)
add_executable(${exe} ${exe}.c ${common_SRCS})
target_compile_options(${exe} PRIVATE ${OPENJP2_COMPILE_OPTIONS})
target_link_libraries(${exe} ${OPENJPEG_LIBRARY_NAME}
${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME}
${JPEG_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME}
)
# To support universal exe:
if(ZLIB_FOUND AND APPLE)
Expand Down
4 changes: 4 additions & 0 deletions src/bin/jp2/convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ int imagetotga(opj_image_t * image, const char *outfile);
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
int imagetobmp(opj_image_t *image, const char *outfile);

/* JPEG conversion*/
opj_image_t* jpegtoimage(const char *filename, opj_cparameters_t *parameters);
int imagetojpeg(opj_image_t *image, const char *outfile);

/* TIFF conversion*/
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters,
const unsigned int target_bitdepth);
Expand Down
Loading

0 comments on commit 836944d

Please sign in to comment.