OPJViewer opens now BMP, PNG, GIF, PNM, TIFF (with wxWidgets internals); added an encoder settings tab, for future integration with "save file as..." in JPEG 2000 format

This commit is contained in:
Giuseppe Baruffa 2007-06-03 17:34:46 +00:00
parent 814bab6900
commit adc1aacb60
8 changed files with 897 additions and 346 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPEG
! : changed
+ : added
June 2, 2007
+ [GB] OPJViewer opens now BMP, PNG, GIF, PNM, TIFF (with wxWidgets internals); added an encoder settings tab, for future integration with "save file as..." in JPEG 2000 format
May 31, 2007
* [FOD] Fixed the handling of 16bit TIFF files for cinema compression. Modified "convert.c"
* [FOD] Fixed the parameters used for cinema compression (9-7 transform used instead of 5-3). Modified "image_to_j2k.c"

View File

@ -42,15 +42,15 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# 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" /D "OPJ_MANYFORMATS" /FR /FD /c
# 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
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
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 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
!ELSEIF "$(CFG)" == "OPJViewer - Win32 Debug"
@ -97,6 +97,11 @@ SOURCE=.\source\imagjp2.cpp
# End Source File
# Begin Source File
SOURCE=.\source\imagjpeg2000.cpp
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\source\imagmj2.cpp
# End Source File
# Begin Source File

View File

@ -193,6 +193,13 @@ bool OPJViewerApp::OnInit(void)
wxImage::AddHandler( new wxJ2KHandler );
wxImage::AddHandler( new wxJP2Handler );
wxImage::AddHandler( new wxMJ2Handler );
#endif
#if OPJ_MANYFORMATS
wxImage::AddHandler( new wxBMPHandler );
wxImage::AddHandler( new wxPNGHandler );
wxImage::AddHandler( new wxGIFHandler );
wxImage::AddHandler( new wxPNMHandler );
wxImage::AddHandler( new wxTIFFHandler );
#endif
// we use a XPM image in our HTML page
wxImage::AddHandler(new wxXPMHandler);
@ -268,6 +275,7 @@ BEGIN_EVENT_TABLE(OPJFrame, wxMDIParentFrame)
EVT_MENU(OPJFRAME_VIEWRELOAD, OPJFrame::OnReload)
EVT_MENU(OPJFRAME_FILETOGGLEB, OPJFrame::OnToggleBrowser)
EVT_MENU(OPJFRAME_FILETOGGLEP, OPJFrame::OnTogglePeeker)
EVT_MENU(OPJFRAME_SETSENCO, OPJFrame::OnSetsEnco)
EVT_MENU(OPJFRAME_SETSDECO, OPJFrame::OnSetsDeco)
EVT_SASH_DRAGGED_RANGE(OPJFRAME_BROWSEWIN, OPJFRAME_LOGWIN, OPJFrame::OnSashDrag)
EVT_NOTEBOOK_PAGE_CHANGED(LEFT_NOTEBOOK_ID, OPJFrame::OnNotebook)
@ -311,6 +319,9 @@ OPJFrame::OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title,
// settings menu and its items
wxMenu *sets_menu = new wxMenu;
sets_menu->Append(OPJFRAME_SETSENCO, wxT("&Encoder\tCtrl+E"));
sets_menu->SetHelpString(OPJFRAME_SETSENCO, wxT("Encoder settings"));
sets_menu->Append(OPJFRAME_SETSDECO, wxT("&Decoder\tCtrl+D"));
sets_menu->SetHelpString(OPJFRAME_SETSDECO, wxT("Decoder settings"));
@ -444,6 +455,15 @@ void OPJFrame::Resize(int number)
wxSize size = GetClientSize();
}
void OPJFrame::OnSetsEnco(wxCommandEvent& event)
{
OPJEncoderDialog dialog(this, event.GetId());
if (dialog.ShowModal() == wxID_OK) {
};
}
void OPJFrame::OnSetsDeco(wxCommandEvent& event)
{
OPJDecoderDialog dialog(this, event.GetId());
@ -717,9 +737,22 @@ void OPJFrame::OnFileOpen(wxCommandEvent& WXUNUSED(event))
#ifdef __WXMOTIF__
wxT("JPEG 2000 files (*.jp2,*.j2k,*.j2c,*.mj2)|*.*j*2*");
#else
wxT("JPEG 2000 files (*.jp2,*.j2k,*.j2c,*.mj2)|*.jp2;*.j2k;*.j2c;*.mj2|JPEG files (*.jpg)|*.jpg|All files|*");
#if wxUSE_LIBOPENJPEG
wxT("JPEG 2000 files (*.jp2,*.j2k,*.j2c,*.mj2)|*.jp2;*.j2k;*.j2c;*.mj2")
#endif
wxFileDialog dialog(this, _T("Open JPEG 2000 file(s)"),
#if wxUSE_LIBJPEG
wxT("|JPEG files (*.jpg)|*.jpg")
#endif
#if OPJ_MANYFORMATS
wxT("|BMP files (*.bmp)|*.bmp")
wxT("|PNG files (*.png)|*.png")
wxT("|GIF files (*.gif)|*.gif")
wxT("|PNM files (*.pnm)|*.pnm")
wxT("|TIFF files (*.tif,*.tiff)|*.tif*")
#endif
wxT("|All files|*");
#endif
wxFileDialog dialog(this, _T("Open image file(s)"),
wxEmptyString, wxEmptyString, wildcards,
wxFD_OPEN|wxFD_MULTIPLE);
@ -2082,110 +2115,6 @@ OPJDecoderDialog::~OPJDecoderDialog()
{
}
/*wxPanel* OPJDecoderDialog::CreateGeneralSettingsPage(wxWindow* parent)
{
wxPanel* panel = new wxPanel(parent, wxID_ANY);
wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
//// LOAD LAST FILE
wxBoxSizer* itemSizer3 = new wxBoxSizer( wxHORIZONTAL );
wxCheckBox* checkBox3 = new wxCheckBox(panel, ID_LOAD_LAST_PROJECT, _("&Load last project on startup"), wxDefaultPosition, wxDefaultSize);
itemSizer3->Add(checkBox3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
item0->Add(itemSizer3, 0, wxGROW|wxALL, 0);
//// AUTOSAVE
wxString autoSaveLabel = _("&Auto-save every");
wxString minsLabel = _("mins");
wxBoxSizer* itemSizer12 = new wxBoxSizer( wxHORIZONTAL );
wxCheckBox* checkBox12 = new wxCheckBox(panel, ID_AUTO_SAVE, autoSaveLabel, wxDefaultPosition, wxDefaultSize);
wxSpinCtrl* spinCtrl12 = new wxSpinCtrl(panel, ID_AUTO_SAVE_MINS, wxEmptyString,
wxDefaultPosition, wxSize(40, wxDefaultCoord), wxSP_ARROW_KEYS, 1, 60, 1);
itemSizer12->Add(checkBox12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
itemSizer12->Add(spinCtrl12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
itemSizer12->Add(new wxStaticText(panel, wxID_STATIC, minsLabel), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
item0->Add(itemSizer12, 0, wxGROW|wxALL, 0);
//// TOOLTIPS
wxBoxSizer* itemSizer8 = new wxBoxSizer( wxHORIZONTAL );
wxCheckBox* checkBox6 = new wxCheckBox(panel, ID_SHOW_TOOLTIPS, _("Show &tooltips"), wxDefaultPosition, wxDefaultSize);
itemSizer8->Add(checkBox6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
item0->Add(itemSizer8, 0, wxGROW|wxALL, 0);
topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
panel->SetSizer(topSizer);
topSizer->Fit(panel);
return panel;
}*/
/*wxPanel* OPJDecoderDialog::CreateAestheticSettingsPage(wxWindow* parent)
{
wxPanel* panel = new wxPanel(parent, wxID_ANY);
wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
//// PROJECT OR GLOBAL
wxString globalOrProjectChoices[2];
globalOrProjectChoices[0] = _("&New projects");
globalOrProjectChoices[1] = _("&This project");
wxRadioBox* projectOrGlobal = new wxRadioBox(panel, ID_APPLY_SETTINGS_TO, _("&Apply settings to:"),
wxDefaultPosition, wxDefaultSize, 2, globalOrProjectChoices);
item0->Add(projectOrGlobal, 0, wxGROW|wxALL, 5);
projectOrGlobal->SetSelection(0);
//// BACKGROUND STYLE
wxArrayString backgroundStyleChoices;
backgroundStyleChoices.Add(wxT("Colour"));
backgroundStyleChoices.Add(wxT("Image"));
wxStaticBox* staticBox3 = new wxStaticBox(panel, wxID_ANY, _("Background style:"));
wxBoxSizer* styleSizer = new wxStaticBoxSizer( staticBox3, wxVERTICAL );
item0->Add(styleSizer, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemSizer2 = new wxBoxSizer( wxHORIZONTAL );
wxChoice* choice2 = new wxChoice(panel, ID_BACKGROUND_STYLE, wxDefaultPosition, wxDefaultSize, backgroundStyleChoices);
itemSizer2->Add(new wxStaticText(panel, wxID_ANY, _("&Window:")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
itemSizer2->Add(5, 5, 1, wxALL, 0);
itemSizer2->Add(choice2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
styleSizer->Add(itemSizer2, 0, wxGROW|wxALL, 5);
#if wxUSE_SPINCTRL
//// FONT SIZE SELECTION
wxStaticBox* staticBox1 = new wxStaticBox(panel, wxID_ANY, _("Tile font size:"));
wxBoxSizer* itemSizer5 = new wxStaticBoxSizer( staticBox1, wxHORIZONTAL );
wxSpinCtrl* spinCtrl = new wxSpinCtrl(panel, ID_FONT_SIZE, wxEmptyString, wxDefaultPosition,
wxSize(80, wxDefaultCoord));
itemSizer5->Add(spinCtrl, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
item0->Add(itemSizer5, 0, wxGROW|wxLEFT|wxRIGHT, 5);
#endif
topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
topSizer->AddSpacer(5);
panel->SetSizer(topSizer);
topSizer->Fit(panel);
return panel;
}*/
wxPanel* OPJDecoderDialog::CreateMainSettingsPage(wxWindow* parent)
{
wxPanel* panel = new wxPanel(parent, wxID_ANY);
@ -2348,7 +2277,7 @@ wxPanel* OPJDecoderDialog::CreatePart1SettingsPage(wxWindow* parent)
wxBoxSizer* numcompsSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
numcompsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&No. of components:")),
numcompsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Component displayed:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
// add some horizontal space
@ -2362,7 +2291,7 @@ wxPanel* OPJDecoderDialog::CreatePart1SettingsPage(wxWindow* parent)
wxSP_ARROW_KEYS,
0, 100000, wxGetApp().m_components),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
m_numcompsCtrl->Enable(false);
m_numcompsCtrl->Enable(true);
compoSizer->Add(numcompsSizer, 0, wxGROW | wxALL, 5);
@ -2516,3 +2445,525 @@ bool OPJDnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames)
return true;
}
// ----------------------------------------------------------------------------
// OPJEncoderDialog
// ----------------------------------------------------------------------------
IMPLEMENT_CLASS(OPJEncoderDialog, wxPropertySheetDialog)
BEGIN_EVENT_TABLE(OPJEncoderDialog, wxPropertySheetDialog)
#ifdef USE_JPWL
EVT_CHECKBOX(OPJENCO_ENABLEJPWL, OPJEncoderDialog::OnEnableJPWL)
#endif // USE_JPWL
END_EVENT_TABLE()
OPJEncoderDialog::OPJEncoderDialog(wxWindow* win, int dialogType)
{
SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
Create(win, wxID_ANY, wxT("Encoder settings"),
wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE| (int) wxPlatform::IfNot(wxOS_WINDOWS_CE, wxRESIZE_BORDER)
);
CreateButtons(wxOK | wxCANCEL | (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP));
m_settingsNotebook = GetBookCtrl();
wxPanel* mainSettings = CreateMainSettingsPage(m_settingsNotebook);
wxPanel* jpeg2000Settings = CreatePart1SettingsPage(m_settingsNotebook);
/* if (!wxGetApp().m_enabledeco)
jpeg2000Settings->Enable(false);
wxPanel* mjpeg2000Settings = CreatePart3SettingsPage(m_settingsNotebook);
if (!wxGetApp().m_enabledeco)
mjpeg2000Settings->Enable(false);
#ifdef USE_JPWL
wxPanel* jpwlSettings = CreatePart11SettingsPage(m_settingsNotebook);
if (!wxGetApp().m_enabledeco)
jpwlSettings->Enable(false);
#endif // USE_JPWL
*/
m_settingsNotebook->AddPage(mainSettings, wxT("General"), false);
m_settingsNotebook->AddPage(jpeg2000Settings, wxT("JPEG 2000"), false);
/* m_settingsNotebook->AddPage(mjpeg2000Settings, wxT("MJPEG 2000"), false);
#ifdef USE_JPWL
m_settingsNotebook->AddPage(jpwlSettings, wxT("JPWL"), false);
#endif // USE_JPWL
*/
LayoutDialog();
}
OPJEncoderDialog::~OPJEncoderDialog()
{
}
wxPanel* OPJEncoderDialog::CreateMainSettingsPage(wxWindow* parent)
{
wxPanel* panel = new wxPanel(parent, wxID_ANY);
// top sizer
wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
// sub top sizer
wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL);
topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5);
// assign top and fit it
panel->SetSizer(topSizer);
topSizer->Fit(panel);
return panel;
}
wxPanel* OPJEncoderDialog::CreatePart1SettingsPage(wxWindow* parent)
{
wxPanel* panel = new wxPanel(parent, wxID_ANY);
// top sizer
wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
// add some space
//topSizer->AddSpacer(5);
// sub top sizer
wxFlexGridSizer *subtopSizer = new wxFlexGridSizer(2, 3, 3);
// image settings, column
wxStaticBox* imageBox = new wxStaticBox(panel, wxID_ANY, wxT("Image"));
wxBoxSizer* imageSizer = new wxStaticBoxSizer(imageBox, wxVERTICAL);
// subsampling factor sizer, row
wxBoxSizer* subsSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
subsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Subsampling:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
// add some horizontal space
subsSizer->Add(3, 3, 1, wxALL, 0);
// add the value control
subsSizer->Add(
/*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_SUBSAMPLING,
wxT("1,1"),
wxDefaultPosition, wxSize(120, wxDefaultCoord),
wxTE_LEFT),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
imageSizer->Add(subsSizer, 0, wxGROW | wxALL, 3);
// origin sizer, row
wxBoxSizer* imorigSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
imorigSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Origin:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
// add some horizontal space
imorigSizer->Add(3, 3, 1, wxALL, 0);
// add the value control
imorigSizer->Add(
/*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_IMORIG,
wxT("0,0"),
wxDefaultPosition, wxSize(120, wxDefaultCoord),
wxTE_LEFT),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
imageSizer->Add(imorigSizer, 0, wxGROW | wxALL, 3);
subtopSizer->Add(imageSizer, 0, wxGROW | wxALL, 3);
// layer settings, column
wxStaticBox* layerBox = new wxStaticBox(panel, wxID_ANY, wxT("Layers"));
wxBoxSizer* layerSizer = new wxStaticBoxSizer(layerBox, wxVERTICAL);
// rate factor sizer, row
wxBoxSizer* rateSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
rateSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Rate values:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
// add some horizontal space
rateSizer->Add(3, 3, 1, wxALL, 0);
// add the value control
rateSizer->Add(
/*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_RATEFACTOR,
wxT("20,10,5"),
wxDefaultPosition, wxSize(120, wxDefaultCoord),
wxTE_LEFT),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
layerSizer->Add(rateSizer, 0, wxGROW | wxALL, 3);
// quality factor sizer, row
wxBoxSizer* qualitySizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
qualitySizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Quality values:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
// add some horizontal space
qualitySizer->Add(3, 3, 1, wxALL, 0);
// add the value control
qualitySizer->Add(
/*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_QUALITYFACTOR,
wxT("30,35,40"),
wxDefaultPosition, wxSize(120, wxDefaultCoord),
wxTE_LEFT),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
layerSizer->Add(qualitySizer, 0, wxGROW | wxALL, 3);
subtopSizer->Add(layerSizer, 0, wxGROW | wxALL, 3);
// wavelet settings, column
wxStaticBox* waveletBox = new wxStaticBox(panel, wxID_ANY, wxT("Transform"));
wxBoxSizer* waveletSizer = new wxStaticBoxSizer(waveletBox, wxVERTICAL);
// irreversible check box
waveletSizer->Add(
/*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLEIRREV, wxT("Irreversible"),
wxDefaultPosition, wxDefaultSize),
0, wxGROW | wxALL, 3);
/*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/
// resolution number sizer, row
wxBoxSizer* resnumSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
resnumSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Resolutions:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
// add some horizontal space
resnumSizer->Add(3, 3, 1, wxALL, 0);
// add the value control
resnumSizer->Add(
/*m_layerCtrl =*/ new wxSpinCtrl(panel, OPJENCO_RESNUMBER,
wxT("6"),
wxDefaultPosition, wxSize(80, wxDefaultCoord),
wxSP_ARROW_KEYS,
0, 256, 6),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
waveletSizer->Add(resnumSizer, 0, wxGROW | wxALL, 3);
// codeblock sizer, row
wxBoxSizer* codeblockSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
codeblockSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Codeblocks size:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
// add some horizontal space
codeblockSizer->Add(3, 3, 1, wxALL, 0);
// add the value control
codeblockSizer->Add(
/*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_CODEBLOCKSIZE,
wxT("32,32"),
wxDefaultPosition, wxSize(120, wxDefaultCoord),
wxTE_LEFT),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
waveletSizer->Add(codeblockSizer, 0, wxGROW | wxALL, 3);
// precinct sizer, row
wxBoxSizer* precinctSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
precinctSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Precincts size:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
// add some horizontal space
precinctSizer->Add(3, 3, 1, wxALL, 0);
// add the value control
precinctSizer->Add(
/*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_PRECINCTSIZE,
wxT("[128,128],[128,128]"),
wxDefaultPosition, wxSize(120, wxDefaultCoord),
wxTE_LEFT),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
waveletSizer->Add(precinctSizer, 0, wxGROW | wxALL, 3);
subtopSizer->Add(waveletSizer, 0, wxGROW | wxALL, 3);
// tile settings, column
wxStaticBox* tileBox = new wxStaticBox(panel, wxID_ANY, wxT("Tiles"));
wxBoxSizer* tileSizer = new wxStaticBoxSizer(tileBox, wxVERTICAL);
// tile size sizer, row
wxBoxSizer* tilesizeSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
tilesizeSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Size:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
// add some horizontal space
tilesizeSizer->Add(3, 3, 1, wxALL, 0);
// add the value control
tilesizeSizer->Add(
/*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_TILESIZE,
wxT(""),
wxDefaultPosition, wxSize(120, wxDefaultCoord),
wxTE_LEFT),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
tileSizer->Add(tilesizeSizer, 0, wxGROW | wxALL, 3);
// tile origin sizer, row
wxBoxSizer* tilorigSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
tilorigSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Origin:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
// add some horizontal space
tilorigSizer->Add(3, 3, 1, wxALL, 0);
// add the value control
tilorigSizer->Add(
/*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_TILORIG,
wxT("0,0"),
wxDefaultPosition, wxSize(120, wxDefaultCoord),
wxTE_LEFT),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
tileSizer->Add(tilorigSizer, 0, wxGROW | wxALL, 3);
subtopSizer->Add(tileSizer, 0, wxGROW | wxALL, 3);
// progression settings, column
wxString choices[] = {wxT("LRCP"), wxT("RLCP"), wxT("RPCL"), wxT("PCRL"), wxT("CPRL")};
wxRadioBox *progressionBox = new wxRadioBox(panel, OPJENCO_PROGRESSION,
wxT("Progression"),
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(choices),
choices,
4,
wxRA_SPECIFY_COLS);
progressionBox->SetSelection(0);
subtopSizer->Add(progressionBox, 0, wxGROW | wxALL, 3);
// resilience settings, column
wxStaticBox* resilBox = new wxStaticBox(panel, wxID_ANY, wxT("Resilience"));
wxBoxSizer* resilSizer = new wxStaticBoxSizer(resilBox, wxVERTICAL);
// resil2 sizer, row
wxBoxSizer* resil2Sizer = new wxBoxSizer(wxHORIZONTAL);
// SOP check box
resil2Sizer->Add(
/*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLESOP, wxT("SOP"),
wxDefaultPosition, wxDefaultSize),
0, wxGROW | wxALL, 3);
/*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/
// EPH check box
resil2Sizer->Add(
/*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLEEPH, wxT("EPH"),
wxDefaultPosition, wxDefaultSize),
0, wxGROW | wxALL, 3);
/*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/
resilSizer->Add(resil2Sizer, 0, wxGROW | wxALL, 3);
// separation
resilSizer->Add(new wxStaticLine(panel, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 3);
// resil3 sizer, row
wxFlexGridSizer* resil3Sizer = new wxFlexGridSizer(3, 3, 3);
// BYPASS check box
resil3Sizer->Add(
/*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLEBYPASS, wxT("BYPASS"),
wxDefaultPosition, wxDefaultSize),
0, wxGROW | wxALL, 3);
/*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/
// RESET check box
resil3Sizer->Add(
/*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLERESET, wxT("RESET"),
wxDefaultPosition, wxDefaultSize),
0, wxGROW | wxALL, 3);
/*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/
// RESTART check box
resil3Sizer->Add(
/*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLERESTART, wxT("RESTART"),
wxDefaultPosition, wxDefaultSize),
0, wxGROW | wxALL, 3);
/*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/
// VSC check box
resil3Sizer->Add(
/*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLEVSC, wxT("VSC"),
wxDefaultPosition, wxDefaultSize),
0, wxGROW | wxALL, 3);
/*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/
// ERTERM check box
resil3Sizer->Add(
/*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLEERTERM, wxT("ERTERM"),
wxDefaultPosition, wxDefaultSize),
0, wxGROW | wxALL, 3);
/*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/
// SEGMARK check box
resil3Sizer->Add(
/*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLESEGMARK, wxT("SEGMARK"),
wxDefaultPosition, wxDefaultSize),
0, wxGROW | wxALL, 3);
/*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/
resilSizer->Add(resil3Sizer, 0, wxGROW | wxALL, 3);
subtopSizer->Add(resilSizer, 0, wxGROW | wxALL, 3);
// ROI settings, column
wxStaticBox* roiBox = new wxStaticBox(panel, wxID_ANY, wxT("ROI"));
wxBoxSizer* roiSizer = new wxStaticBoxSizer(roiBox, wxVERTICAL);
// component number sizer, row
wxBoxSizer* roicompSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
roicompSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Component:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
// add some horizontal space
roicompSizer->Add(3, 3, 1, wxALL, 0);
// add the value control
roicompSizer->Add(
/*m_layerCtrl =*/ new wxSpinCtrl(panel, OPJENCO_ROICOMP,
wxT("0"),
wxDefaultPosition, wxSize(80, wxDefaultCoord),
wxSP_ARROW_KEYS,
0, 256, 0),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
roiSizer->Add(roicompSizer, 0, wxGROW | wxALL, 3);
// upshift sizer, row
wxBoxSizer* roishiftSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
roishiftSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Upshift:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
// add some horizontal space
roishiftSizer->Add(3, 3, 1, wxALL, 0);
// add the value control
roishiftSizer->Add(
/*m_layerCtrl =*/ new wxSpinCtrl(panel, OPJENCO_ROISHIFT,
wxT("0"),
wxDefaultPosition, wxSize(80, wxDefaultCoord),
wxSP_ARROW_KEYS,
0, 37, 0),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
roiSizer->Add(roishiftSizer, 0, wxGROW | wxALL, 3);
subtopSizer->Add(roiSizer, 0, wxGROW | wxALL, 3);
// ROI settings, column
wxStaticBox* indexBox = new wxStaticBox(panel, wxID_ANY, wxT("Indexing"));
wxBoxSizer* indexSizer = new wxStaticBoxSizer(indexBox, wxVERTICAL);
// indexing check box
indexSizer->Add(
/*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLEINDEX, wxT("Enabled"),
wxDefaultPosition, wxDefaultSize),
0, wxGROW | wxALL, 3);
/*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/
// index file sizer, row
wxBoxSizer* indexnameSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
indexnameSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&File name:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
// add some horizontal space
indexnameSizer->Add(3, 3, 1, wxALL, 0);
// add the value control
indexnameSizer->Add(
/*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_INDEXNAME,
wxT(""),
wxDefaultPosition, wxSize(120, wxDefaultCoord),
wxTE_LEFT),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
indexSizer->Add(indexnameSizer, 0, wxGROW | wxALL, 3);
subtopSizer->Add(indexSizer, 0, wxGROW | wxALL, 3);
/* // component settings, column
wxStaticBox* compoBox = new wxStaticBox(panel, wxID_ANY, wxT("Components"));
wxBoxSizer* compoSizer = new wxStaticBoxSizer(compoBox, wxVERTICAL);
// quality layers sizer, row
wxBoxSizer* numcompsSizer = new wxBoxSizer(wxHORIZONTAL);
// add some text
numcompsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Component displayed:")),
0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
// add some horizontal space
numcompsSizer->Add(5, 5, 1, wxALL, 0);
// add the value control
numcompsSizer->Add(
m_numcompsCtrl = new wxSpinCtrl(panel, OPJDECO_NUMCOMPS,
wxString::Format(wxT("%d"), wxGetApp().m_components),
wxDefaultPosition, wxSize(80, wxDefaultCoord),
wxSP_ARROW_KEYS,
0, 100000, wxGetApp().m_components),
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
m_numcompsCtrl->Enable(true);
compoSizer->Add(numcompsSizer, 0, wxGROW | wxALL, 5);
subtopSizer->Add(compoSizer, 0, wxGROW | wxALL, 5);
*/
topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5);
// assign top and fit it
panel->SetSizer(topSizer);
topSizer->Fit(panel);
return panel;
}
#ifdef USE_JPWL
void OPJEncoderDialog::OnEnableJPWL(wxCommandEvent& event)
{
/*if (event.IsChecked()) {
wxLogMessage(wxT("JPWL enabled"));
m_expcompsCtrl->Enable(true);
m_maxtilesCtrl->Enable(true);
} else {
wxLogMessage(wxT("JPWL disabled"));
m_expcompsCtrl->Enable(false);
m_maxtilesCtrl->Enable(false);
}*/
}
#endif // USE_JPWL

View File

@ -371,6 +371,7 @@ class OPJFrame: public wxMDIParentFrame
void OnToggleBrowser(wxCommandEvent& WXUNUSED(event));
void OnTogglePeeker(wxCommandEvent& WXUNUSED(event));
void OnReload(wxCommandEvent& event);
void OnSetsEnco(wxCommandEvent& event);
void OnSetsDeco(wxCommandEvent& event);
void OnSashDrag(wxSashEvent& event);
void OpenFiles(wxArrayString paths, wxArrayString filenames);
@ -434,6 +435,7 @@ enum {
OPJFRAME_VIEWFIT,
OPJFRAME_VIEWRELOAD,
OPJFRAME_FILECLOSE,
OPJFRAME_SETSENCO,
OPJFRAME_SETSDECO,
OPJFRAME_BROWSEWIN = 10000,
@ -556,7 +558,59 @@ private:
// Property sheet dialog
// Property sheet dialog: encoder
class OPJEncoderDialog: public wxPropertySheetDialog
{
DECLARE_CLASS(OPJEncoderDialog)
public:
OPJEncoderDialog(wxWindow* parent, int dialogType);
~OPJEncoderDialog();
wxBookCtrlBase* m_settingsNotebook;
wxPanel* CreateMainSettingsPage(wxWindow* parent);
wxPanel* CreatePart1SettingsPage(wxWindow* parent);
/* wxPanel* CreatePart3SettingsPage(wxWindow* parent);*/
#ifdef USE_JPWL
void OnEnableJPWL(wxCommandEvent& event);
/* wxPanel* CreatePart11SettingsPage(wxWindow* parent);
wxCheckBox *m_enablejpwlCheck;*/
#endif // USE_JPWL
protected:
enum {
OPJENCO_ENABLEJPWL = 100,
OPJENCO_RATEFACTOR,
OPJENCO_QUALITYFACTOR,
OPJENCO_RESNUMBER,
OPJENCO_CODEBLOCKSIZE,
OPJENCO_PRECINCTSIZE,
OPJENCO_TILESIZE,
OPJENCO_PROGRESSION,
OPJENCO_SUBSAMPLING,
OPJENCO_ENABLESOP,
OPJENCO_ENABLEEPH,
OPJENCO_ENABLEBYPASS,
OPJENCO_ENABLERESET,
OPJENCO_ENABLERESTART,
OPJENCO_ENABLEVSC,
OPJENCO_ENABLEERTERM,
OPJENCO_ENABLESEGMARK,
OPJENCO_ROICOMP,
OPJENCO_ROISHIFT,
OPJENCO_IMORIG,
OPJENCO_TILORIG,
OPJENCO_ENABLEIRREV,
OPJENCO_ENABLEINDEX,
OPJENCO_INDEXNAME
};
DECLARE_EVENT_TABLE()
};
// Property sheet dialog: decoder
class OPJDecoderDialog: public wxPropertySheetDialog
{
DECLARE_CLASS(OPJDecoderDialog)

View File

@ -85,27 +85,41 @@ void j2k_error_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("[ERROR] %.*s"), message_len, msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
/* sample warning callback expecting a FILE* client object */
void j2k_warning_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("[WARNING] %.*s"), message_len, msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
/* sample debug callback expecting no client object */
void j2k_info_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("[INFO] %.*s"), message_len, msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
// load the j2k codestream
@ -117,8 +131,6 @@ bool wxJ2KHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
unsigned char *src = NULL;
unsigned char *ptr;
int file_length;
int shiftbpp;
int c, tempcomps;
// destroy the image
image->Destroy();
@ -146,8 +158,6 @@ bool wxJ2KHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
parameters.cp_reduce = m_reducefactor;
if (m_qualitylayers)
parameters.cp_layer = m_qualitylayers;
/*if (n_components)
parameters. = n_components;*/
/* JPWL only */
#ifdef USE_JPWL
@ -180,9 +190,13 @@ bool wxJ2KHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
/* decode the stream and fill the image structure */
opjimage = opj_decode(dinfo, cio);
if (!opjimage) {
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogError(wxT("J2K: failed to decode image!"));
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
opj_destroy_decompress(dinfo);
opj_cio_close(cio);
opj_image_destroy(opjimage);
@ -193,125 +207,16 @@ bool wxJ2KHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
/* close the byte stream */
opj_cio_close(cio);
// check image components
// check image depth (only on the first one, for now)
shiftbpp = opjimage->comps[0].prec - 8;
// prepare image size
image->Create(opjimage->comps[0].w, opjimage->comps[0].h, true );
// access image raw data
image->SetMask( false );
ptr = image->GetData();
// workaround for components different from 1 or 3
if ((opjimage->numcomps != 1) && (opjimage->numcomps != 3)) {
wxMutexGuiEnter();
wxLogMessage(wxT("J2K: weird number of components"));
tempcomps = 1;
wxMutexGuiLeave();
} else
tempcomps = opjimage->numcomps;
// workaround for subsampled components
for (c = 1; c < tempcomps; c++) {
if ((opjimage->comps[c].w != opjimage->comps[c - 1].w) || (opjimage->comps[c].h != opjimage->comps[c - 1].h)) {
tempcomps = 1;
break;
}
}
// workaround for different precision components
for (c = 1; c < tempcomps; c++) {
if (opjimage->comps[c].bpp != opjimage->comps[c - 1].bpp) {
tempcomps = 1;
break;
}
}
// RGB color picture
if (tempcomps == 3) {
int row, col;
int *r = opjimage->comps[0].data;
int *g = opjimage->comps[1].data;
int *b = opjimage->comps[2].data;
if (shiftbpp > 0) {
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
*(ptr++) = (*(r++)) >> shiftbpp;
*(ptr++) = (*(g++)) >> shiftbpp;
*(ptr++) = (*(b++)) >> shiftbpp;
}
}
} else if (shiftbpp < 0) {
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
*(ptr++) = (*(r++)) << -shiftbpp;
*(ptr++) = (*(g++)) << -shiftbpp;
*(ptr++) = (*(b++)) << -shiftbpp;
}
}
} else {
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
*(ptr++) = *(r++);
*(ptr++) = *(g++);
*(ptr++) = *(b++);
}
}
}
}
// B/W picture
if (tempcomps == 1) {
int row, col;
int *y = opjimage->comps[0].data;
if (shiftbpp > 0) {
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
*(ptr++) = (*(y)) >> shiftbpp;
*(ptr++) = (*(y)) >> shiftbpp;
*(ptr++) = (*(y++)) >> shiftbpp;
}
}
} else if (shiftbpp < 0) {
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
*(ptr++) = (*(y)) << -shiftbpp;
*(ptr++) = (*(y)) << -shiftbpp;
*(ptr++) = (*(y++)) << -shiftbpp;
}
}
} else {
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
*(ptr++) = *(y);
*(ptr++) = *(y);
*(ptr++) = *(y++);
}
}
}
}
/* common rendering method */
#include "imagjpeg2000.cpp"
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("J2K: image loaded."));
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
/* close openjpeg structs */
opj_destroy_decompress(dinfo);
@ -328,7 +233,14 @@ bool wxJ2KHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
// save the j2k codestream
bool wxJ2KHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbose )
{
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogError(wxT("J2K: Couldn't save image -> not implemented."));
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
return false;
}

View File

@ -89,30 +89,43 @@ void jp2_error_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
wxMutexGuiEnter();
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("[ERROR] %.*s"), message_len, msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
/* sample warning callback expecting a FILE* client object */
void jp2_warning_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
wxMutexGuiEnter();
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("[WARNING] %.*s"), message_len, msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
/* sample debug callback expecting no client object */
void jp2_info_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
wxMutexGuiEnter();
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("[INFO] %.*s"), message_len, msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
// load the jp2 file format
bool wxJP2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose, int index)
{
@ -182,9 +195,13 @@ bool wxJP2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
/* decode the stream and fill the image structure */
opjimage = opj_decode(dinfo, cio);
if (!opjimage) {
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogError(wxT("JP2: failed to decode image!"));
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
opj_destroy_decompress(dinfo);
opj_cio_close(cio);
free(src);
@ -194,59 +211,16 @@ bool wxJP2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
/* close the byte stream */
opj_cio_close(cio);
// check image size
if ((opjimage->numcomps != 1) && (opjimage->numcomps != 3)) {
/* common rendering method */
#include "imagjpeg2000.cpp"
#ifndef __WXGTK__
wxMutexGuiEnter();
wxLogError(wxT("JP2: weird number of components"));
wxMutexGuiLeave();
opj_destroy_decompress(dinfo);
free(src);
return false;
}
// prepare image size
image->Create(opjimage->comps[0].w, opjimage->comps[0].h, true );
// access image raw data
image->SetMask( false );
ptr = image->GetData();
// RGB color picture
if (opjimage->numcomps == 3) {
int row, col;
int *r = opjimage->comps[0].data;
int *g = opjimage->comps[1].data;
int *b = opjimage->comps[2].data;
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
*(ptr++) = *(r++);
*(ptr++) = *(g++);
*(ptr++) = *(b++);
}
}
}
// B/W picture
if (opjimage->numcomps == 1) {
int row, col;
int *y = opjimage->comps[0].data;
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
*(ptr++) = *(y);
*(ptr++) = *(y);
*(ptr++) = *(y++);
}
}
}
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("JP2: image loaded."));
wxMutexGuiLeave();
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
/* close openjpeg structs */
opj_destroy_decompress(dinfo);
@ -263,7 +237,14 @@ bool wxJP2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
// save the jp2 file format
bool wxJP2Handler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbose )
{
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogError(wxT("JP2: Couldn't save image -> not implemented."));
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
return false;
}

View File

@ -0,0 +1,186 @@
/*
* Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/////////////////////////////////////////////////////////////////////////////
// Name: imagjpeg2000.cpp
// Purpose: wxImage JPEG 2000 imagage rendering common functions
// Author: Giuseppe Baruffa
// RCS-ID: $Id: imagjpeg2000.cpp,v 0.00 2007/04/27 22:11:00 MW Exp $
// Copyright: (c) Giuseppe Baruffa
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/*
- At this point, we have the structure "opjimage" that is filled with decompressed
data, as processed by the OpenJPEG decompression engine
- We need to fill the class "image" with the proper pixel sample values
*/
{
int shiftbpp;
int c, tempcomps;
// check components number
if (m_components > opjimage->numcomps)
m_components = opjimage->numcomps;
// check image depth (only on the first one, for now)
if (m_components)
shiftbpp = opjimage->comps[m_components - 1].prec - 8;
else
shiftbpp = opjimage->comps[0].prec - 8;
// prepare image size
if (m_components)
image->Create(opjimage->comps[m_components - 1].w, opjimage->comps[m_components - 1].h, true);
else
image->Create(opjimage->comps[0].w, opjimage->comps[0].h, true);
// access image raw data
image->SetMask(false);
ptr = image->GetData();
// workaround for components different from 1 or 3
if ((opjimage->numcomps != 1) && (opjimage->numcomps != 3)) {
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("JPEG2000: weird number of components"));
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
tempcomps = 1;
} else
tempcomps = opjimage->numcomps;
// workaround for subsampled components
for (c = 1; c < tempcomps; c++) {
if ((opjimage->comps[c].w != opjimage->comps[c - 1].w) || (opjimage->comps[c].h != opjimage->comps[c - 1].h)) {
tempcomps = 1;
break;
}
}
// workaround for different precision components
for (c = 1; c < tempcomps; c++) {
if (opjimage->comps[c].bpp != opjimage->comps[c - 1].bpp) {
tempcomps = 1;
break;
}
}
// only one component selected
if (m_components)
tempcomps = 1;
// RGB color picture
if (tempcomps == 3) {
int row, col;
int *r = opjimage->comps[0].data;
int *g = opjimage->comps[1].data;
int *b = opjimage->comps[2].data;
if (shiftbpp > 0) {
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
*(ptr++) = (*(r++)) >> shiftbpp;
*(ptr++) = (*(g++)) >> shiftbpp;
*(ptr++) = (*(b++)) >> shiftbpp;
}
}
} else if (shiftbpp < 0) {
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
*(ptr++) = (*(r++)) << -shiftbpp;
*(ptr++) = (*(g++)) << -shiftbpp;
*(ptr++) = (*(b++)) << -shiftbpp;
}
}
} else {
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
*(ptr++) = *(r++);
*(ptr++) = *(g++);
*(ptr++) = *(b++);
}
}
}
}
// B/W picture
if (tempcomps == 1) {
int row, col;
int selcomp;
if (m_components)
selcomp = m_components - 1;
else
selcomp = 0;
int *y = opjimage->comps[selcomp].data;
if (shiftbpp > 0) {
for (row = 0; row < opjimage->comps[selcomp].h; row++) {
for (col = 0; col < opjimage->comps[selcomp].w; col++) {
*(ptr++) = (*(y)) >> shiftbpp;
*(ptr++) = (*(y)) >> shiftbpp;
*(ptr++) = (*(y++)) >> shiftbpp;
}
}
} else if (shiftbpp < 0) {
for (row = 0; row < opjimage->comps[selcomp].h; row++) {
for (col = 0; col < opjimage->comps[selcomp].w; col++) {
*(ptr++) = (*(y)) << -shiftbpp;
*(ptr++) = (*(y)) << -shiftbpp;
*(ptr++) = (*(y++)) << -shiftbpp;
}
}
} else {
for (row = 0; row < opjimage->comps[selcomp].h; row++) {
for (col = 0; col < opjimage->comps[selcomp].w; col++) {
*(ptr++) = *(y);
*(ptr++) = *(y);
*(ptr++) = *(y++);
}
}
}
}
}

View File

@ -89,27 +89,41 @@ void mj2_error_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
wxMutexGuiEnter();
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("[ERROR] %.*s"), message_len, msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
/* sample warning callback expecting a FILE* client object */
void mj2_warning_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
wxMutexGuiEnter();
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("[WARNING] %.*s"), message_len, msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
/* sample debug callback expecting no client object */
void mj2_info_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
wxMutexGuiEnter();
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("[INFO] %.*s"), message_len, msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
/* macro functions */
@ -691,63 +705,8 @@ bool wxMJ2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
/* close the byte stream */
opj_cio_close(cio);
// check image size
if ((opjimage->numcomps != 1) && (opjimage->numcomps != 3)) {
wxMutexGuiEnter();
wxLogError(wxT("MJ2: weird number of components"));
wxMutexGuiLeave();
opj_destroy_decompress(dinfo);
free(src);
return false;
}
// prepare image size
image->Create(opjimage->comps[0].w, opjimage->comps[0].h, true );
// access image raw data
image->SetMask( false );
ptr = image->GetData();
// RGB color picture
// does not handle comps. subsampling,
// so simply render the first component
if (opjimage->numcomps == 3) {
int row, col;
int *r = opjimage->comps[0].data;
/*
int *g = opjimage->comps[1].data;
int *b = opjimage->comps[2].data;
*/
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
/*
*(ptr++) = *(r++);
*(ptr++) = *(g++);
*(ptr++) = *(b++);
*/
*(ptr++) = *(r);
*(ptr++) = *(r);
*(ptr++) = *(r++);
}
}
}
// B/W picture
if (opjimage->numcomps == 1) {
int row, col;
int *y = opjimage->comps[0].data;
for (row = 0; row < opjimage->comps[0].h; row++) {
for (col = 0; col < opjimage->comps[0].w; col++) {
*(ptr++) = *(y);
*(ptr++) = *(y);
*(ptr++) = *(y++);
}
}
}
/* common rendering method */
#include "imagjpeg2000.cpp"
wxMutexGuiEnter();
wxLogMessage(wxT("MJ2: image loaded."));