enable/disable decoding in OPJViewer

This commit is contained in:
Giuseppe Baruffa 2007-04-22 22:41:01 +00:00
parent 110b54c7c6
commit fbc9a5edcb
7 changed files with 126 additions and 28 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPEG
! : changed ! : changed
+ : added + : added
April 23, 2007
+ [GB] Enable/disable image decoding in OPJViewer
April 12,2007 April 12,2007
* [Parvatha] Fixed Error in tiftoimage(). Modification in convert.c. * [Parvatha] Fixed Error in tiftoimage(). Modification in convert.c.

View File

@ -42,15 +42,15 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /G6 /MD /W3 /GX /O2 /I "d:\programmi\wxWidgets-2.8.0\lib\vc_lib\msw" /I "d:\programmi\wxWidgets-2.8.0\include" /I ".." /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /D "wxUSE_LIBOPENJPEG" /D "OPJ_STATIC" /D "USE_JPWL" /D "OPJ_HTMLABOUT" /FR /FD /c # ADD CPP /nologo /G6 /MD /W3 /GX /O2 /I "c:\programmi\wxWidgets-2.8.0\lib\vc_lib\msw" /I "c:\programmi\wxWidgets-2.8.0\include" /I ".." /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /D "wxUSE_LIBOPENJPEG" /D "OPJ_STATIC" /D "USE_JPWL" /D "OPJ_HTMLABOUT" /FR /FD /c
# ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD BASE RSC /l 0x410 /d "NDEBUG"
# ADD RSC /l 0x409 /i "d:\programmi\wxWidgets-2.8.0\include" /d "NDEBUG" # ADD RSC /l 0x409 /i "c:\programmi\wxWidgets-2.8.0\include" /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxzlib.lib wxregex.lib wxpng.lib wxjpeg.lib wxbase28.lib wxmsw28_core.lib wxmsw28_html.lib wxmsw28_adv.lib wxmsw28_core.lib wxbase28.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib LibOpenJPEG_JPWL.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libcmt.lib" /libpath:"d:\programmi\wxWidgets-2.8.0\lib\vc_lib" /libpath:"..\jpwl\Release" /IGNORE:4089 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxzlib.lib wxregex.lib wxpng.lib wxjpeg.lib wxbase28.lib wxmsw28_core.lib wxmsw28_html.lib wxmsw28_adv.lib wxmsw28_core.lib wxbase28.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib LibOpenJPEG_JPWL.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libcmt.lib" /libpath:"c:\programmi\wxWidgets-2.8.0\lib\vc_lib" /libpath:"..\jpwl\Release" /IGNORE:4089
# SUBTRACT LINK32 /pdb:none # SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "OPJViewer - Win32 Debug" !ELSEIF "$(CFG)" == "OPJViewer - Win32 Debug"

View File

@ -17,26 +17,31 @@ This document describes the installation and use of the OPJViewer in the framewo
This implementation has been developed using the OpenJPEG library as decoding engine and wxWidgets 2.8.0 as GUI engine. This implementation has been developed using the OpenJPEG library as decoding engine and wxWidgets 2.8.0 as GUI engine.
If you find some bugs or if you have problems using the encoder/decoder, please send an e-mail to jpwl@diei.unipg.it If you find some bugs or if you have problems using the viewer, please send an e-mail to jpwl@diei.unipg.it
2. Installing the viewer 2. Installing the viewer
========================== ==========================
There are two available options, at the moment: a) compile from source code, and b) download a precompiled binary. In order to perform option a), it is mandatory to have compiled and built the LibOpenJPEG_JPWL library and the wxWidgets 2.8.0 framework (you have to download it from http://www.wxwidgets.org/ and compile the wx* libraries). There are two options available, at the moment:
a) compile from source code
b) download a precompiled binary.
In order to use option a), it is mandatory to have compiled and built the LibOpenJPEG_JPWL library and the wxWidgets 2.8.0 framework (you have to download it from http://www.wxwidgets.org/ and compile the wx* libraries).
2.1. Compiling the source code in Windows 2.1. Compiling the source code in Windows
------------------------------------------- -------------------------------------------
These are the steps required to compile the viewer under windows. The steps required to compile the viewer under windows are:
a) Download at least the libonjpeg, jpwl, and opjviewer folders from the SVN trunk. a) Download at least the libopenjpeg, jpwl, and opjviewer folders from the SVN trunk.
b) Open the OPJViewer.dsw workspace with Visual C++ 6 and activate the "OPJViewer - Win32 Release" configuration. b) Open the OPJViewer.dsw workspace with Visual C++ 6 and activate the "OPJViewer - Win32 Release" configuration.
c) In the configuration settings, go to the C++ tab and modify the wxWidgets paths in order to reflect your wx* install configuration (Preprocessor -> Additional include directories): simply update each instance of the two wx paths, do not remove or add them. c) In the configuration settings, go to the C++ tab and modify the wxWidgets paths in order to reflect your wx* install configuration (Preprocessor -> Additional include directories): simply update each instance of the two wx paths, do not remove or add them.
d) In the configuration settings, go to the Link tab and modify the wxWidgets path in order to reflect your wx* install configuration (Input -> Additional library path): simply update the wx path. d) In the configuration settings, go to the Link tab and modify the wxWidgets path in order to reflect your wx* install configuration (Input -> Additional library path): simply update the wx path.
e) In the configuration settings, go to the Resources tab and modify the wxWidgets path in order to reflect your wx* install configuration (Additional resource include directories): simply update the wx path. e) In the configuration settings, go to the Resources tab and modify the wxWidgets path in order to reflect your wx* install configuration (Additional resource include directories): simply update the wx path.
f) Build! f) Build!
g) Run! g) Run!
h) (OPTIONAL) Prepare an installer by compiling the InnoSetup script OPJViewer.iss (you need to download it from http://www.jrsoftware.org/isinfo.php). h) (OPTIONAL) Prepare an installer by compiling the InnoSetup script OPJViewer.iss (you need to download InnoSetup from http://www.jrsoftware.org/isinfo.php).
2.2. Compiling the source code in Unix-like systems 2.2. Compiling the source code in Unix-like systems
----------------------------------------------------- -----------------------------------------------------
@ -47,8 +52,9 @@ The porting is possible and under way.
3. General information on the viewer 3. General information on the viewer
==================================== ====================================
This viewer is conceived to open and display information and image of J2K, JP2, and MJ2 files. This viewer is conceived to open and display information and image content of J2K, JP2,
The viewer application graphical interface is divided into three main panels: and MJ2 files.
The viewer application interface is divided into three main panels:
- a browsing pane; - a browsing pane;
- a viewing pane; - a viewing pane;
- a log/peek pane. - a log/peek pane.
@ -92,4 +98,4 @@ The log/peek pane is shared among two different subpanels:
4.2. Limitations 4.2. Limitations
------------------ ------------------
* For mj2 files, only the first frame is displayed, and only in B/W * For mj2 files, rendering is only in B/W

View File

@ -201,6 +201,7 @@ bool OPJViewerApp::OnInit(void)
wxFileSystem::AddHandler(new wxMemoryFSHandler); wxFileSystem::AddHandler(new wxMemoryFSHandler);
// set decoding engine parameters // set decoding engine parameters
m_enabledeco = true;
m_resizemethod = 0; m_resizemethod = 0;
m_reducefactor = 0; m_reducefactor = 0;
m_qualitylayers = 0; m_qualitylayers = 0;
@ -450,6 +451,7 @@ void OPJFrame::OnSetsDeco(wxCommandEvent& event)
if (dialog.ShowModal() == wxID_OK) { if (dialog.ShowModal() == wxID_OK) {
// load settings // load settings
wxGetApp().m_enabledeco = dialog.m_enabledecoCheck->GetValue();
wxGetApp().m_resizemethod = dialog.m_resizeBox->GetSelection(); wxGetApp().m_resizemethod = dialog.m_resizeBox->GetSelection();
wxGetApp().m_reducefactor = dialog.m_reduceCtrl->GetValue(); wxGetApp().m_reducefactor = dialog.m_reduceCtrl->GetValue();
wxGetApp().m_qualitylayers = dialog.m_layerCtrl->GetValue(); wxGetApp().m_qualitylayers = dialog.m_layerCtrl->GetValue();
@ -748,6 +750,7 @@ OPJCanvas::OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos, con
// 100% zoom // 100% zoom
m_zooml = 100; m_zooml = 100;
OPJDecoThread *dthread = CreateDecoThread(); OPJDecoThread *dthread = CreateDecoThread();
if (dthread->Run() != wxTHREAD_NO_ERROR) if (dthread->Run() != wxTHREAD_NO_ERROR)
@ -1840,9 +1843,6 @@ void *OPJDecoThread::Entry()
// GetId(), GetPriority(), m_countnum); // GetId(), GetPriority(), m_countnum);
text.Printf(wxT("Deco thread %d started"), m_canvas->m_childframe->m_winnumber); text.Printf(wxT("Deco thread %d started"), m_canvas->m_childframe->m_winnumber);
WriteText(text); WriteText(text);
wxBitmap bitmap(100, 100); wxBitmap bitmap(100, 100);
@ -1884,10 +1884,22 @@ void *OPJDecoThread::Entry()
mj222handler->m_maxtiles = wxGetApp().m_maxtiles; mj222handler->m_maxtiles = wxGetApp().m_maxtiles;
#endif // USE_JPWL #endif // USE_JPWL
// load the file if (wxGetApp().m_enabledeco) {
if (!image.LoadFile(m_canvas->m_fname.GetFullPath(), wxBITMAP_TYPE_ANY), 0) {
WriteText(wxT("Can't load image")); // load the file
return NULL; if (!image.LoadFile(m_canvas->m_fname.GetFullPath(), wxBITMAP_TYPE_ANY, 0)) {
WriteText(wxT("Can't load image"));
return NULL;
}
} else {
// display a macaron
if (!image.Create(300, 5, false)) {
WriteText(wxT("Can't create image"));
return NULL;
}
} }
// assign 100% image // assign 100% image
@ -2021,6 +2033,7 @@ IMPLEMENT_CLASS(OPJDecoderDialog, wxPropertySheetDialog)
BEGIN_EVENT_TABLE(OPJDecoderDialog, wxPropertySheetDialog) BEGIN_EVENT_TABLE(OPJDecoderDialog, wxPropertySheetDialog)
#ifdef USE_JPWL #ifdef USE_JPWL
EVT_CHECKBOX(OPJDECO_ENABLEDECO, OPJDecoderDialog::OnEnableDeco)
EVT_CHECKBOX(OPJDECO_ENABLEJPWL, OPJDecoderDialog::OnEnableJPWL) EVT_CHECKBOX(OPJDECO_ENABLEJPWL, OPJDecoderDialog::OnEnableJPWL)
#endif // USE_JPWL #endif // USE_JPWL
END_EVENT_TABLE() END_EVENT_TABLE()
@ -2036,20 +2049,26 @@ OPJDecoderDialog::OPJDecoderDialog(wxWindow* win, int dialogType)
CreateButtons(wxOK | wxCANCEL | (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP)); CreateButtons(wxOK | wxCANCEL | (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP));
wxBookCtrlBase* notebook = GetBookCtrl(); m_settingsNotebook = GetBookCtrl();
wxPanel* mainSettings = CreateMainSettingsPage(notebook); wxPanel* mainSettings = CreateMainSettingsPage(m_settingsNotebook);
wxPanel* jpeg2000Settings = CreatePart1SettingsPage(notebook); wxPanel* jpeg2000Settings = CreatePart1SettingsPage(m_settingsNotebook);
wxPanel* mjpeg2000Settings = CreatePart3SettingsPage(notebook); if (!wxGetApp().m_enabledeco)
jpeg2000Settings->Enable(false);
wxPanel* mjpeg2000Settings = CreatePart3SettingsPage(m_settingsNotebook);
if (!wxGetApp().m_enabledeco)
mjpeg2000Settings->Enable(false);
#ifdef USE_JPWL #ifdef USE_JPWL
wxPanel* jpwlSettings = CreatePart11SettingsPage(notebook); wxPanel* jpwlSettings = CreatePart11SettingsPage(m_settingsNotebook);
if (!wxGetApp().m_enabledeco)
jpwlSettings->Enable(false);
#endif // USE_JPWL #endif // USE_JPWL
notebook->AddPage(mainSettings, wxT("Display"), false); m_settingsNotebook->AddPage(mainSettings, wxT("Display"), false);
notebook->AddPage(jpeg2000Settings, wxT("JPEG 2000"), false); m_settingsNotebook->AddPage(jpeg2000Settings, wxT("JPEG 2000"), false);
notebook->AddPage(mjpeg2000Settings, wxT("MJPEG 2000"), false); m_settingsNotebook->AddPage(mjpeg2000Settings, wxT("MJPEG 2000"), false);
#ifdef USE_JPWL #ifdef USE_JPWL
notebook->AddPage(jpwlSettings, wxT("JPWL"), false); m_settingsNotebook->AddPage(jpwlSettings, wxT("JPWL"), false);
#endif // USE_JPWL #endif // USE_JPWL
LayoutDialog(); LayoutDialog();
@ -2173,6 +2192,12 @@ wxPanel* OPJDecoderDialog::CreateMainSettingsPage(wxWindow* parent)
// sub top sizer // sub top sizer
wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL);
// add decoding enabling check box
subtopSizer->Add(
m_enabledecoCheck = new wxCheckBox(panel, OPJDECO_ENABLEDECO, wxT("Enable decoding"), wxDefaultPosition, wxDefaultSize),
0, wxGROW | wxALL, 5);
m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);
// resize settings, column // resize settings, column
wxString choices[] = {wxT("Low quality"), wxT("High quality")}; wxString choices[] = {wxT("Low quality"), wxT("High quality")};
m_resizeBox = new wxRadioBox(panel, OPJDECO_RESMETHOD, m_resizeBox = new wxRadioBox(panel, OPJDECO_RESMETHOD,
@ -2433,6 +2458,30 @@ wxPanel* OPJDecoderDialog::CreatePart11SettingsPage(wxWindow* parent)
return panel; return panel;
} }
void OPJDecoderDialog::OnEnableDeco(wxCommandEvent& event)
{
size_t pp;
if (event.IsChecked()) {
wxLogMessage(wxT("Decoding enabled"));
m_resizeBox->Enable(true);
// enable all tabs except ourselves
for (pp = 0; pp < m_settingsNotebook->GetPageCount(); pp++) {
if (m_settingsNotebook->GetPageText(pp) != wxT("Display"))
m_settingsNotebook->GetPage(pp)->Enable(true);
}
} else {
wxLogMessage(wxT("Decoding disabled"));
m_resizeBox->Enable(false);
// disable all tabs except ourselves
for (pp = 0; pp < m_settingsNotebook->GetPageCount(); pp++) {
if (m_settingsNotebook->GetPageText(pp) != wxT("Display"))
m_settingsNotebook->GetPage(pp)->Enable(false);
}
}
}
void OPJDecoderDialog::OnEnableJPWL(wxCommandEvent& event) void OPJDecoderDialog::OnEnableJPWL(wxCommandEvent& event)
{ {
if (event.IsChecked()) { if (event.IsChecked()) {

View File

@ -182,6 +182,7 @@ class OPJViewerApp: public wxApp
int m_resizemethod; int m_resizemethod;
// decoding engine parameters // decoding engine parameters
bool m_enabledeco;
int m_reducefactor, m_qualitylayers, m_components, m_framenum; int m_reducefactor, m_qualitylayers, m_components, m_framenum;
#ifdef USE_JPWL #ifdef USE_JPWL
bool m_enablejpwl; bool m_enablejpwl;
@ -562,9 +563,13 @@ public:
OPJDecoderDialog(wxWindow* parent, int dialogType); OPJDecoderDialog(wxWindow* parent, int dialogType);
~OPJDecoderDialog(); ~OPJDecoderDialog();
wxBookCtrlBase* m_settingsNotebook;
wxCheckBox *m_enabledecoCheck;
wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl; wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl;
wxRadioBox* m_resizeBox; wxRadioBox* m_resizeBox;
void OnEnableDeco(wxCommandEvent& event);
wxPanel* CreateMainSettingsPage(wxWindow* parent); wxPanel* CreateMainSettingsPage(wxWindow* parent);
wxPanel* CreatePart1SettingsPage(wxWindow* parent); wxPanel* CreatePart1SettingsPage(wxWindow* parent);
wxPanel* CreatePart3SettingsPage(wxWindow* parent); wxPanel* CreatePart3SettingsPage(wxWindow* parent);
@ -583,6 +588,7 @@ protected:
OPJDECO_REDUCEFACTOR, OPJDECO_REDUCEFACTOR,
OPJDECO_QUALITYLAYERS, OPJDECO_QUALITYLAYERS,
OPJDECO_NUMCOMPS, OPJDECO_NUMCOMPS,
OPJDECO_ENABLEDECO,
OPJDECO_ENABLEJPWL, OPJDECO_ENABLEJPWL,
OPJDECO_EXPCOMPS, OPJDECO_EXPCOMPS,
OPJDECO_MAXTILES, OPJDECO_MAXTILES,

View File

@ -4,6 +4,7 @@ Copyright (c) 2001-2003, David Janssens
Copyright (c) 2002-2003, Yannick Verschueren Copyright (c) 2002-2003, Yannick Verschueren
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
Copyright (c) 2005, Herve Drolon, FreeImage Team Copyright (c) 2005, Herve Drolon, FreeImage Team
Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditionsare met: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditionsare met:

View File

@ -1 +1,34 @@
Good choice! This viewer is conceived to open and display information and image content of J2K, JP2,
and MJ2 files.
The viewer application interface is divided into three main panels:
- a browsing pane;
- a viewing pane;
- a log/peek pane.
The browsing pane will present the markers or boxes hierarchy, with position (byte number where marker/box starts and stops) and length information (i.e., inner length as signalled by marker/box and total length, with marker/box sign included), in the following form:
filename
|
|_ #000: Marker/Box short name (Hex code)
| |
| |_ *** Marker/Box long name ***
| |_ startbyte > stopbyte, inner_length + marker/box sign length (total length)
| |_ Additional info, depending on the marker/box type
| |_ ...
|
|_ #001: Marker/Box short name (Hex code)
| |
| |_ ...
|
...
The viewing pane will display the decoded image contained in the JPEG 2000 file.
It should display correctly images as large as 4000x2000, provided that a couple of GB of RAM are available. Nothing is known about the display of larger sizes: let us know if you manage to get it working.
The log/peek pane is shared among two different subpanels:
- the log panel will report a lot of debugging info coming out from the wx GUI as well as from the openjpeg library
- the peek pane tries to give a peek on the codestream/file portion which is currently selected in the browsing pane. It shows both hex and ascii values corresponding to the marker/box section.