Possibility to disable parsing in OPJViewer; also, saves common settings to the registry; automatic build numbering

This commit is contained in:
Giuseppe Baruffa
2007-06-16 17:28:47 +00:00
parent 3d626da232
commit 2845d9bf64
12 changed files with 153 additions and 43 deletions

View File

@@ -207,8 +207,30 @@ bool OPJViewerApp::OnInit(void)
// memory file system
wxFileSystem::AddHandler(new wxMemoryFSHandler);
#ifdef OPJ_INICONFIG
//load decoding engine parameters
OPJconfig = new wxConfig(OPJ_APPLICATION, OPJ_APPLICATION_VENDOR);
OPJconfig->Read(wxT("enabledeco"), &m_enabledeco, (bool) true);
OPJconfig->Read(wxT("enableparse"), &m_enableparse, (bool) true);
OPJconfig->Read(wxT("resizemethod"), &m_resizemethod, (long) 0);
OPJconfig->Read(wxT("reducefactor"), &m_reducefactor, (long) 0);
OPJconfig->Read(wxT("qualitylayers"), &m_qualitylayers, (long) 0);
OPJconfig->Read(wxT("components"), &m_components, (long) 0);
OPJconfig->Read(wxT("framenum"), &m_framenum, (long) 0);
#ifdef USE_JPWL
OPJconfig->Read(wxT("enablejpwl"), &m_enablejpwl, (bool) true);
OPJconfig->Read(wxT("expcomps"), &m_expcomps, (long) JPWL_EXPECTED_COMPONENTS);
OPJconfig->Read(wxT("maxtiles"), &m_maxtiles, (long) JPWL_MAXIMUM_TILES);
#endif // USE_JPWL
OPJconfig->Write(wxT("teststring"), wxT("This is a test value"));
OPJconfig->Write(wxT("testbool"), (bool) true);
OPJconfig->Write(wxT("testlong"), (long) 245);
#else
// set decoding engine parameters
m_enabledeco = true;
m_enableparse = true;
m_resizemethod = 0;
m_reducefactor = 0;
m_qualitylayers = 0;
@@ -219,6 +241,7 @@ bool OPJViewerApp::OnInit(void)
m_expcomps = JPWL_EXPECTED_COMPONENTS;
m_maxtiles = JPWL_MAXIMUM_TILES;
#endif // USE_JPWL
#endif // OPJ_INICONFIG
// Create the main frame window
OPJFrame *frame = new OPJFrame(NULL, wxID_ANY, OPJ_APPLICATION_TITLEBAR,
@@ -250,6 +273,26 @@ bool OPJViewerApp::OnInit(void)
return true;
}
int OPJViewerApp::OnExit()
{
#ifdef OPJ_INICONFIG
OPJconfig->Write(wxT("enabledeco"), m_enabledeco);
OPJconfig->Write(wxT("enableparse"), m_enableparse);
OPJconfig->Write(wxT("resizemethod"), m_resizemethod);
OPJconfig->Write(wxT("reducefactor"), m_reducefactor);
OPJconfig->Write(wxT("qualitylayers"), m_qualitylayers);
OPJconfig->Write(wxT("components"), m_components);
OPJconfig->Write(wxT("framenum"), m_framenum);
#ifdef USE_JPWL
OPJconfig->Write(wxT("enablejpwl"), m_enablejpwl);
OPJconfig->Write(wxT("expcomps"), m_expcomps);
OPJconfig->Write(wxT("maxtiles"), m_maxtiles);
#endif // USE_JPWL
#endif // OPJ_INICONFIG
return 1;
}
void OPJViewerApp::ShowCmdLine(const wxCmdLineParser& parser)
{
wxString s = wxT("Command line parsed successfully:\nInput files: ");
@@ -472,7 +515,8 @@ void OPJFrame::OnSetsDeco(wxCommandEvent& event)
// load settings
wxGetApp().m_enabledeco = dialog.m_enabledecoCheck->GetValue();
wxGetApp().m_resizemethod = dialog.m_resizeBox->GetSelection();
wxGetApp().m_enableparse = dialog.m_enableparseCheck->GetValue();
wxGetApp().m_resizemethod = dialog.m_resizeBox->GetSelection() - 1;
wxGetApp().m_reducefactor = dialog.m_reduceCtrl->GetValue();
wxGetApp().m_qualitylayers = dialog.m_layerCtrl->GetValue();
wxGetApp().m_components = dialog.m_numcompsCtrl->GetValue();
@@ -548,16 +592,23 @@ void OPJFrame::OnZoom(wxCommandEvent& WXUNUSED(event))
void OPJFrame::Rescale(int zooml, OPJChildFrame *currframe)
{
wxImage new_image = currframe->m_canvas->m_image100.ConvertToImage();
// resizing enabled?
if (wxGetApp().m_resizemethod == -1) {
zooml = 100;
}
if (zooml != 100)
new_image.Rescale((int) ((double) zooml * (double) new_image.GetWidth() / 100.0),
(int) ((double) zooml * (double) new_image.GetHeight() / 100.0),
wxGetApp().m_resizemethod ? wxIMAGE_QUALITY_HIGH : wxIMAGE_QUALITY_NORMAL);
currframe->m_canvas->m_image = wxBitmap(new_image);
currframe->m_canvas->m_image = wxBitmap(new_image);
currframe->m_canvas->SetScrollbars(20,
20,
(int)(0.5 + (double) new_image.GetWidth() / 20.0),
(int)(0.5 + (double) new_image.GetHeight() / 20.0)
);
currframe->m_canvas->Refresh();
// update zoom
@@ -1125,32 +1176,39 @@ void OPJParseThread::LoadFile(wxFileName fname)
// open the file
wxFile m_file(fname.GetFullPath().c_str(), wxFile::read);
// what is the extension?
if ((fname.GetExt() == wxT("j2k")) || (fname.GetExt() == wxT("j2c"))) {
// parsing enabled?
if (wxGetApp().m_enableparse) {
// parse the file
ParseJ2KFile(&m_file, 0, m_file.Length(), rootid);
// what is the extension?
if ((fname.GetExt() == wxT("j2k")) || (fname.GetExt() == wxT("j2c"))) {
} else if ((fname.GetExt() == wxT("jp2")) || (fname.GetExt() == wxT("mj2"))) {
// parse the file
ParseJ2KFile(&m_file, 0, m_file.Length(), rootid);
// parse the file
if (this->m_parentid) {
//WriteText(wxT("Only a subsection of jp2"));
OPJMarkerData *data = (OPJMarkerData *) m_tree->GetItemData(rootid);
ParseJ2KFile(&m_file, data->m_start, data->m_length, rootid);
m_tree->Expand(rootid);
} else if ((fname.GetExt() == wxT("jp2")) || (fname.GetExt() == wxT("mj2"))) {
} else
// as usual
ParseJP2File(&m_file, 0, m_file.Length(), rootid);
// parse the file
if (this->m_parentid) {
//WriteText(wxT("Only a subsection of jp2"));
OPJMarkerData *data = (OPJMarkerData *) m_tree->GetItemData(rootid);
ParseJ2KFile(&m_file, data->m_start, data->m_length, rootid);
m_tree->Expand(rootid);
} else {
} else {
// as usual
ParseJP2File(&m_file, 0, m_file.Length(), rootid);
}
// unknown extension
WriteText(wxT("Unknown file format!"));
} else {
// unknown extension
WriteText(wxT("Unknown file format!"));
}
}
// this is the root node
if (this->m_parentid)
m_tree->SetItemText(rootid, wxT("Codestream"));
@@ -2131,8 +2189,14 @@ wxPanel* OPJDecoderDialog::CreateMainSettingsPage(wxWindow* parent)
0, wxGROW | wxALL, 5);
m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);
// add parsing enabling check box
subtopSizer->Add(
m_enableparseCheck = new wxCheckBox(panel, OPJDECO_ENABLEPARSE, wxT("Enable parsing"), wxDefaultPosition, wxDefaultSize),
0, wxGROW | wxALL, 5);
m_enableparseCheck->SetValue(wxGetApp().m_enableparse);
// resize settings, column
wxString choices[] = {wxT("Low quality"), wxT("High quality")};
wxString choices[] = {wxT("Don't resize"), wxT("Low quality"), wxT("High quality")};
m_resizeBox = new wxRadioBox(panel, OPJDECO_RESMETHOD,
wxT("Resize method"),
wxDefaultPosition, wxDefaultSize,
@@ -2140,7 +2204,7 @@ wxPanel* OPJDecoderDialog::CreateMainSettingsPage(wxWindow* parent)
choices,
1,
wxRA_SPECIFY_ROWS);
m_resizeBox->SetSelection(wxGetApp().m_resizemethod);
m_resizeBox->SetSelection(wxGetApp().m_resizemethod + 1);
subtopSizer->Add(m_resizeBox, 0, wxGROW | wxALL, 5);

View File

@@ -128,6 +128,7 @@ typedef unsigned long long int8byte;
#define OPJ_APPLICATION_VERSION wxT("0.3 alpha")
#define OPJ_APPLICATION_TITLEBAR OPJ_APPLICATION_NAME wxT(" ") OPJ_APPLICATION_VERSION
#define OPJ_APPLICATION_COPYRIGHT wxT("(C) 2007, Giuseppe Baruffa")
#define OPJ_APPLICATION_VENDOR wxT("OpenJPEG")
#ifdef __WXMSW__
#define OPJ_APPLICATION_PLATFORM wxT("Windows")
@@ -158,6 +159,7 @@ class OPJViewerApp: public wxApp
// other methods
bool OnInit(void);
int OnExit(void);
void SetShowImages(bool show) { m_showImages = show; }
bool ShowImages() const { return m_showImages; }
void ShowCmdLine(const wxCmdLineParser& parser);
@@ -183,13 +185,16 @@ class OPJViewerApp: public wxApp
int m_resizemethod;
// decoding engine parameters
bool m_enabledeco;
bool m_enabledeco, m_enableparse;
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
#ifdef USE_JPWL
bool m_enablejpwl;
int m_expcomps, m_maxtiles;
#endif // USE_JPWL
// application configuration
wxConfig *OPJconfig;
// private methods and variables
private:
bool m_showImages, m_showButtons;
@@ -619,7 +624,7 @@ public:
~OPJDecoderDialog();
wxBookCtrlBase* m_settingsNotebook;
wxCheckBox *m_enabledecoCheck;
wxCheckBox *m_enabledecoCheck, *m_enableparseCheck;
wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl;
wxRadioBox* m_resizeBox;
@@ -644,6 +649,7 @@ protected:
OPJDECO_QUALITYLAYERS,
OPJDECO_NUMCOMPS,
OPJDECO_ENABLEDECO,
OPJDECO_ENABLEPARSE,
OPJDECO_ENABLEJPWL,
OPJDECO_EXPCOMPS,
OPJDECO_MAXTILES,

View File

@@ -1,29 +1,31 @@
wxString htmlaboutpage = wxT(
"<html>"
"<body bgcolor=#FFFFFF>"
"<table cellspacing=7 cellpadding=1 border=0 width=100%>"
"<table cellspacing=7 cellpadding=1 border=0 width=100%>"
"<tr>"
"<td rowspan=3 valign=top align=center width=70>"
"<img src=\"memory:opj_logo.xpm\"><br><br>"
"<img src=\"memory:opj_logo.xpm\"><br><br>"
"</td>"
"<td align=center>"
"<font size=+0 color=#000000><b>"
OPJ_APPLICATION " " OPJ_APPLICATION_VERSION
"<font size=+0 color=#000000><b>"
OPJ_APPLICATION " " OPJ_APPLICATION_VERSION
"</b></font><br>"
"<font size=-1 color=#000000><b>A JPEG 2000 image viewer</b></font><br>"
"<font size=-2 color=#000000><b>" OPJ_APPLICATION_PLATFORM " version</b></font>"
"<font size=-1 color=#000000><b>A JPEG 2000 image viewer</b></font><br>"
"<font size=-2 color=#000000><b>" OPJ_APPLICATION_PLATFORM " version</b></font>"
"</td>"
"</tr>"
"<tr height=3 valign=center>"
"<td valign=center bgcolor=#cc3300></td>"
"<tr height=3 valign=center>"
"<td valign=center bgcolor=#cc3300></td>"
"</tr>"
"<tr>"
"<td align=justify>"
"<center><font size=+0 color=#000000><a href=\"http://www.openjpeg.org/\">OpenJPEG</a></font></center>"
"<font size=-1 color=#000000>The OpenJPEG library is an open-source JPEG 2000 codec written in C language. "
"In addition to the basic codec, various other features are under development.</font><br>"
"<font size=-2 color=red>* Build: " wxVERSION_STRING ", " __DATE__ ", " __TIME__ "</font><br>"
)
"<font size=-2 color=red>* Build: ")
#include "build.h"
wxT("</font><br>")
wxT("<font size=-2 color=red>* " wxVERSION_STRING ", " __DATE__ ", " __TIME__ "</font><br>")
#ifdef USE_JPWL
wxT("<font size=-2 color=green>- Compiled with JPWL support</font><br>")
#endif // USE_JPWL
@@ -33,7 +35,7 @@ wxT("<font size=-2 color=green>- Compiled with JPSEC support</font>")
wxT("</td>"
"</tr>"
"<tr>"
"<td colspan=2 bgcolor=#CC3300 height=3 valign=center></td>"
"<td colspan=2 bgcolor=#CC3300 height=3 valign=center></td>"
"</tr>"
"<tr>"
"<td colspan=2>"

1
OPJViewer/source/build.h Normal file
View File

@@ -0,0 +1 @@
wxT("20")

View File

@@ -183,4 +183,4 @@
}
}
}

View File

@@ -130,10 +130,18 @@ void mj2_info_callback(const char *msg, void *client_data) {
/* From little endian to big endian, 2 and 4 bytes */
#define BYTE_SWAP2(X) ((X & 0x00FF) << 8) | ((X & 0xFF00) >> 8)
#define BYTE_SWAP4(X) ((X & 0x000000FF) << 24) | ((X & 0x0000FF00) << 8) | ((X & 0x00FF0000) >> 8) | ((X & 0xFF000000) >> 24)
#ifdef __WXGTK__
#define BYTE_SWAP8(X) ((X & 0x00000000000000FFULL) << 56) | ((X & 0x000000000000FF00ULL) << 40) | \
((X & 0x0000000000FF0000ULL) << 24) | ((X & 0x00000000FF000000ULL) << 8) | \
((X & 0x000000FF00000000ULL) >> 8) | ((X & 0x0000FF0000000000ULL) >> 24) | \
((X & 0x00FF000000000000ULL) >> 40) | ((X & 0xFF00000000000000ULL) >> 56)
#else
#define BYTE_SWAP8(X) ((X & 0x00000000000000FF) << 56) | ((X & 0x000000000000FF00) << 40) | \
((X & 0x0000000000FF0000) << 24) | ((X & 0x00000000FF000000) << 8) | \
((X & 0x000000FF00000000) >> 8) | ((X & 0x0000FF0000000000) >> 24) | \
((X & 0x00FF000000000000) >> 40) | ((X & 0xFF00000000000000) >> 56)
#endif
/* From codestream to int values */
#define STREAM_TO_UINT32(C, P) (((unsigned long int) (C)[(P) + 0] << 24) + \

View File

@@ -303,10 +303,18 @@ struct boxdef j22box[] =
/* From little endian to big endian, 2 and 4 bytes */
#define BYTE_SWAP2(X) ((X & 0x00FF) << 8) | ((X & 0xFF00) >> 8)
#define BYTE_SWAP4(X) ((X & 0x000000FF) << 24) | ((X & 0x0000FF00) << 8) | ((X & 0x00FF0000) >> 8) | ((X & 0xFF000000) >> 24)
#define BYTE_SWAP8(X) (((X & 0x00000000000000FF) << 56) | ((X & 0x000000000000FF00) << 40) | \
#ifdef __WXGTK__
#define BYTE_SWAP8(X) ((X & 0x00000000000000FFULL) << 56) | ((X & 0x000000000000FF00ULL) << 40) | \
((X & 0x0000000000FF0000ULL) << 24) | ((X & 0x00000000FF000000ULL) << 8) | \
((X & 0x000000FF00000000ULL) >> 8) | ((X & 0x0000FF0000000000ULL) >> 24) | \
((X & 0x00FF000000000000ULL) >> 40) | ((X & 0xFF00000000000000ULL) >> 56)
#else
#define BYTE_SWAP8(X) ((X & 0x00000000000000FF) << 56) | ((X & 0x000000000000FF00) << 40) | \
((X & 0x0000000000FF0000) << 24) | ((X & 0x00000000FF000000) << 8) | \
((X & 0x000000FF00000000) >> 8) | ((X & 0x0000FF0000000000) >> 24) | \
((X & 0x00FF000000000000) >> 40) | ((X & 0xFF00000000000000) >> 56))
((X & 0x00FF000000000000) >> 40) | ((X & 0xFF00000000000000) >> 56)
#endif
/* From codestream to int values */
#define STREAM_TO_UINT32(C, P) (((unsigned long int) (C)[(P) + 0] << 24) + \