uclouvain / openjpeg

Official repository of the OpenJPEG project
Other
971 stars 456 forks source link

openjpeg2 viewer fails to build #878

Open jiapei100 opened 7 years ago

jiapei100 commented 7 years ago

ENV: Ubuntu 16.04.1 GCC/G++: 5.4.0

By enabling BUILD_VIEWER, I got the following ERROR messages:

[ 36%] Building C object src/lib/openjpwl/CMakeFiles/openjpwl.dir/__/openmj2/openjpeg.c.o
cd ....../openjpeg/build/src/lib/openjpwl && /usr/bin/cc  -DUSE_JPWL -Dopenjpwl_EXPORTS -I....../openjpeg/build/src/lib/openjp2 -I....../openjpeg/src/lib/openmj2 -I....../openjpeg/src/lib/openjpwl  -fPIC   -o CMakeFiles/openjpwl.dir/__/openmj2/openjpeg.c.o   -c ....../openjpeg/src/lib/openmj2/openjpeg.c
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp: In member function ‘virtual bool wxJPEG2000Handler::LoadFile(wxImage*, wxInputStream&, bool, int)’:
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:677:2: error: ‘opj_event_mgr_t’ was not declared in this scope
  opj_event_mgr_t event_mgr;  /* event manager */
  ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:698:2: error: ‘opj_dinfo_t’ was not declared in this scope
  opj_dinfo_t* dinfo = NULL; 
  ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:698:15: error: ‘dinfo’ was not declared in this scope
  opj_dinfo_t* dinfo = NULL; 
               ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:699:2: error: ‘opj_cio_t’ was not declared in this scope
  opj_cio_t *cio = NULL;
  ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:699:13: error: ‘cio’ was not declared in this scope
  opj_cio_t *cio = NULL;
             ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:702:10: error: ‘event_mgr’ was not declared in this scope
  memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
          ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:731:33: error: ‘CODEC_JP2’ was not declared in this scope
   dinfo = opj_create_decompress(CODEC_JP2);
                                 ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:733:33: error: ‘CODEC_J2K’ was not declared in this scope
   dinfo = opj_create_decompress(CODEC_J2K);
                                 ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:780:21: error: ‘opj_common_ptr’ was not declared in this scope
  opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
                     ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:780:61: error: ‘opj_set_event_mgr’ was not declared in this scope
  opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
                                                             ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:787:38: error: expected ‘)’ before ‘dinfo’
   cio = opj_cio_open((opj_common_ptr)dinfo, src, jpeg2000headSIZE + jp2hboxlen + jp2cboxlen);
                                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:787:92: error: ‘opj_cio_open’ was not declared in this scope
   cio = opj_cio_open((opj_common_ptr)dinfo, src, jpeg2000headSIZE + jp2hboxlen + jp2cboxlen);
                                                                                            ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:789:38: error: expected ‘)’ before ‘dinfo’
   cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
                                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:789:61: error: ‘opj_cio_open’ was not declared in this scope
   cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
                                                             ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:796:56: error: ‘opj_decode_with_info’ was not declared in this scope
  opjimage = opj_decode_with_info(dinfo, cio, &cstr_info);
                                                        ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:801:31: error: ‘opj_destroy_decompress’ was not declared in this scope
   opj_destroy_decompress(dinfo);
                               ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:802:20: error: ‘opj_cio_close’ was not declared in this scope
   opj_cio_close(cio);
                    ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:808:19: error: ‘opj_cio_close’ was not declared in this scope
  opj_cio_close(cio);
                   ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:968:30: error: ‘opj_destroy_decompress’ was not declared in this scope
  opj_destroy_decompress(dinfo);
                              ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp: In member function ‘virtual bool wxJPEG2000Handler::SaveFile(wxImage*, wxOutputStream&, bool)’:
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:988:9: error: ‘opj_event_mgr_t’ was not declared in this scope
         opj_event_mgr_t event_mgr;  /* event manager */
         ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:991:9: error: ‘opj_cio_t’ was not declared in this scope
         opj_cio_t *cio = NULL;
         ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:991:20: error: ‘cio’ was not declared in this scope
         opj_cio_t *cio = NULL;
                    ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1002:17: error: ‘event_mgr’ was not declared in this scope
         memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
                 ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1011:32: error: ‘OFF’ was not declared in this scope
         parameters.cp_cinema = OFF;
                                ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1104:51: error: invalid cast from type ‘wxCStrData’ to type ‘char*’
                 char *s = (char *) m_prsize.c_str();
                                                   ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1151:41: error: ‘LRCP’ was not declared in this scope
                 parameters.prog_order = LRCP;
                                         ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1156:41: error: ‘RLCP’ was not declared in this scope
                 parameters.prog_order = RLCP;
                                         ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1161:41: error: ‘RPCL’ was not declared in this scope
                 parameters.prog_order = RPCL;
                                         ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1166:41: error: ‘PCRL’ was not declared in this scope
                 parameters.prog_order = PCRL;
                                         ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1171:41: error: ‘CPRL’ was not declared in this scope
                 parameters.prog_order = CPRL;
                                         ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1176:40: error: ‘CINEMA2K_24’ was not declared in this scope
                 parameters.cp_cinema = CINEMA2K_24;
                                        ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1177:38: error: ‘CINEMA2K’ was not declared in this scope
                 parameters.cp_rsiz = CINEMA2K;
                                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1182:40: error: ‘CINEMA2K_48’ was not declared in this scope
                 parameters.cp_cinema = CINEMA2K_48;
                                        ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1188:40: error: ‘CINEMA4K_24’ was not declared in this scope
                 parameters.cp_cinema = CINEMA4K_24;
                                        ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1189:38: error: ‘CINEMA4K’ was not declared in this scope
                 parameters.cp_rsiz = CINEMA4K;
                                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1220:41: error: ‘CPRL’ was not declared in this scope
                 parameters.prog_order = CPRL;
                                         ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1249:52: error: ‘CLRSPC_SRGB’ was not declared in this scope
         oimage = opj_image_create(3, &cmptparm[0], CLRSPC_SRGB);
                                                    ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1279:22: error: ‘CINEMA2K_24’ was not declared in this scope
                 case CINEMA2K_24:
                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1280:22: error: ‘CINEMA2K_48’ was not declared in this scope
                 case CINEMA2K_48:
                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1288:54: error: ‘STD_RSIZ’ was not declared in this scope
                                 parameters.cp_rsiz = STD_RSIZ;
                                                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1292:22: error: ‘CINEMA4K_24’ was not declared in this scope
                 case CINEMA4K_24:
                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1302:54: error: ‘STD_RSIZ’ was not declared in this scope
                                 parameters.cp_rsiz = STD_RSIZ;
                                                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1310:50: error: ‘CPRL’ was not declared in this scope
                         parameters.POC[0].prg1 = CPRL;
                                                  ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1323:22: error: ‘CINEMA2K_24’ was not declared in this scope
                 case CINEMA2K_24:
                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1324:22: error: ‘CINEMA4K_24’ was not declared in this scope
                 case CINEMA4K_24:
                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1344:22: error: ‘CINEMA2K_48’ was not declared in this scope
                 case CINEMA2K_48:
                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1369:9: error: ‘opj_cinfo_t’ was not declared in this scope
         opj_cinfo_t* cinfo = opj_create_compress(CODEC_J2K);
         ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1369:22: error: ‘cinfo’ was not declared in this scope
         opj_cinfo_t* cinfo = opj_create_compress(CODEC_J2K);
                      ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1369:50: error: ‘CODEC_J2K’ was not declared in this scope
         opj_cinfo_t* cinfo = opj_create_compress(CODEC_J2K);
                                                  ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1372:28: error: ‘opj_common_ptr’ was not declared in this scope
         opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
                            ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1372:68: error: ‘opj_set_event_mgr’ was not declared in this scope
         opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
                                                                    ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1379:44: error: expected ‘)’ before ‘cinfo’
         cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
                                            ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1379:58: error: ‘opj_cio_open’ was not declared in this scope
         cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
                                                          ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1382:71: error: ‘opj_encode_with_info’ was not declared in this scope
         bSuccess = opj_encode_with_info(cinfo, cio, oimage, &cstr_info);
                                                                       ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1385:34: error: ‘opj_cio_close’ was not declared in this scope
                 opj_cio_close(cio);
                                  ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1386:43: error: ‘opj_destroy_compress’ was not declared in this scope
                 opj_destroy_compress(cinfo);
                                           ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1407:41: error: ‘cio_tell’ was not declared in this scope
         codestream_length = cio_tell(cio);
                                         ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1414:26: error: ‘opj_cio_close’ was not declared in this scope
         opj_cio_close(cio);
                          ^
....../openjpeg/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp:1424:35: error: ‘opj_destroy_compress’ was not declared in this scope
         opj_destroy_compress(cinfo);
                                   ^
/usr/bin/cc  -fPIC   -shared -Wl,-soname,libopenjp3d.so.7 -o ../../../bin/libopenjp3d.so.2.1.1 CMakeFiles/openjp3d.dir/bio.c.o CMakeFiles/openjp3d.dir/cio.c.o CMakeFiles/openjp3d.dir/dwt.c.o CMakeFiles/openjp3d.dir/event.c.o CMakeFiles/openjp3d.dir/jp3d.c.o CMakeFiles/openjp3d.dir/jp3d_lib.c.o CMakeFiles/openjp3d.dir/mct.c.o CMakeFiles/openjp3d.dir/mqc.c.o CMakeFiles/openjp3d.dir/openjp3d.c.o CMakeFiles/openjp3d.dir/pi.c.o CMakeFiles/openjp3d.dir/raw.c.o CMakeFiles/openjp3d.dir/t1.c.o CMakeFiles/openjp3d.dir/t1_3d.c.o CMakeFiles/openjp3d.dir/t2.c.o CMakeFiles/openjp3d.dir/tcd.c.o CMakeFiles/openjp3d.dir/tgt.c.o CMakeFiles/openjp3d.dir/volume.c.o -lm 

Cheers Pei

MerlijnWajer commented 3 years ago

There changes will make the viewer compile and start...

... but it seems to have been written for an old(er) wx version. The event registration is wrong, and I get lots of errors about format identifiers being widechars (I think), and the code uses the deprecated wxT all over the place, so that might take quite some time to fix. That said, with below fixes (and just those, I think), I have on occasion have seen the viewer show something.

diff --git a/src/bin/wx/OPJViewer/source/imagjpeg2000.h b/src/bin/wx/OPJViewer/source/imagjpeg2000.h
index ca7f7f29..60770e39 100644
--- a/src/bin/wx/OPJViewer/source/imagjpeg2000.h
+++ b/src/bin/wx/OPJViewer/source/imagjpeg2000.h
@@ -49,6 +49,7 @@
 #if wxUSE_LIBOPENJPEG

 #include "wx/image.h"
+#include "openmj2/openjpeg.h"
 #include "openjp2/openjpeg.h"
 #include "jp2/index.h"

@@ -61,7 +62,7 @@ public:
     {
         m_name = wxT("JPEG 2000 family file format");
         m_extension = wxT("mj2");
-        m_type = wxBITMAP_TYPE_JPEG2000;
+        m_type = (wxBitmapType)wxBITMAP_TYPE_JPEG2000;
         m_mime = wxT("image/mj2");

         /* decoding */

diff --git a/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp b/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp
index 9e1ab90d..93d845db 100644
--- a/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp
+++ b/src/bin/wx/OPJViewer/source/imagjpeg2000.cpp
@@ -56,6 +56,7 @@
 #include "wx/module.h"
 #endif

+#include "openmj2/openjpeg.h"
 #include "openjp2/openjpeg.h"

 #include "wx/filefn.h"
@@ -1204,7 +1205,7 @@ bool wxJPEG2000Handler::SaveFile(wxImage *wimage, wxOutputStream& stream,
     if (m_prsize != wxT("")) {
         char sep;
         int res_spec = 0;
-        char *s = (char *) m_prsize.c_str();
+        const char *s = (const char *) m_prsize.c_str();
         do {
             sep = 0;
             sscanf(s, "[%d,%d]%c", &parameters.prcw_init[res_spec],