OPJconfig->Read(wxT("peekerheight"), &m_peekerheight, (long) OPJ_PEEKER_HEIGHT);\r
OPJconfig->Read(wxT("framewidth"), &m_framewidth, (long) OPJ_FRAME_WIDTH);\r
OPJconfig->Read(wxT("frameheight"), &m_frameheight, (long) OPJ_FRAME_HEIGHT);\r
+\r
+ // load encoding engine parameters\r
+ OPJconfig->Read(wxT("subsampling"), &m_subsampling, (wxString) wxT("1,1"));\r
+ OPJconfig->Read(wxT("origin"), &m_origin, (wxString) wxT("0,0"));\r
+ OPJconfig->Read(wxT("rates"), &m_rates, (wxString) wxT("20,10,5"));\r
+ OPJconfig->Read(wxT("quality"), &m_quality, (wxString) wxT("30,35,40"));\r
+ OPJconfig->Read(wxT("irreversible"), &m_irreversible, (bool) false); \r
+ OPJconfig->Read(wxT("resolutions"), &m_resolutions, (int) 6); \r
+ OPJconfig->Read(wxT("cbsize"), &m_cbsize, (wxString) wxT("32,32"));\r
+ OPJconfig->Read(wxT("prsize"), &m_prsize, (wxString) wxT("[128,128],[128,128]"));\r
+ OPJconfig->Read(wxT("tsize"), &m_tsize, (wxString) wxT(""));\r
+ OPJconfig->Read(wxT("torigin"), &m_torigin, (wxString) wxT("0,0"));\r
+ OPJconfig->Read(wxT("enablesop"), &m_enablesop, (bool) false); \r
+ OPJconfig->Read(wxT("enableeph"), &m_enableeph, (bool) false); \r
+ OPJconfig->Read(wxT("enablecomm"), &m_enablecomm, (bool) true); \r
+ OPJconfig->Read(wxT("comment"), &m_comment, (wxString) wxT(""));\r
+ OPJconfig->Read(wxT("enableidx"), &m_enableidx, (bool) false); \r
+ OPJconfig->Read(wxT("index"), &m_index, (wxString) wxT("index.txt"));\r
+\r
#else\r
// set decoding engine parameters\r
m_enabledeco = true;\r
m_peekerheight = OPJ_PEEKER_HEIGHT;\r
m_framewidth = OPJ_FRAME_WIDTH;\r
m_frameheight = OPJ_FRAME_HEIGHT;\r
+\r
+ // set encoding engine parameters\r
+ m_subsampling = wxT("1,1");\r
+ m_origin = wxT("0,0");\r
+ m_rates = wxT("20,10,5");\r
+ m_quality = wxT("30,35,40");\r
+ m_irreversible = false;\r
+ m_resolutions = 6;\r
+ m_cbsize= wxT("32,32");\r
+ m_prsize= wxT("[128,128],[128,128]");\r
+ m_tsize = wxT("");\r
+ m_torigin = wxT("0,0");\r
+ m_enablesop = false;\r
+ m_enableeph = false;\r
+ m_enableidx = false;\r
+ m_index = wxT("index.txt");\r
+ m_enablecomm = true;\r
+ m_comment = wxT("");\r
+\r
#endif // OPJ_INICONFIG\r
\r
+ if (m_comment == wxT("")) {\r
+#if defined __WXMSW__\r
+ m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG version ");\r
+#elif defined __WXGTK__\r
+ m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");\r
+#else\r
+ m_comment = wxT("Created by OPJViewer - OpenJPEG version ");\r
+#endif\r
+\r
+#ifdef USE_JPWL\r
+ m_comment += wxString::Format("%s with JPWL", opj_version());\r
+#else\r
+ m_comment += wxString::Format("%s", opj_version());\r
+#endif\r
+ }\r
+\r
// Create the main frame window\r
OPJFrame *frame = new OPJFrame(NULL, wxID_ANY, OPJ_APPLICATION_TITLEBAR,\r
wxDefaultPosition, wxSize(wxGetApp().m_framewidth, wxGetApp().m_frameheight),\r
OPJconfig->Write(wxT("peekerheight"), m_peekerheight);\r
OPJconfig->Write(wxT("framewidth"), m_framewidth);\r
OPJconfig->Write(wxT("frameheight"), m_frameheight);\r
+\r
+ OPJconfig->Write(wxT("subsampling"), m_subsampling);\r
+ OPJconfig->Write(wxT("origin"), m_origin);\r
+ OPJconfig->Write(wxT("rates"), m_rates);\r
+ OPJconfig->Write(wxT("quality"), m_quality);\r
+ OPJconfig->Write(wxT("irreversible"), m_irreversible);\r
+ OPJconfig->Write(wxT("resolutions"), m_resolutions);\r
+ OPJconfig->Write(wxT("cbsize"), m_cbsize);\r
+ OPJconfig->Write(wxT("prsize"), m_prsize);\r
+ OPJconfig->Write(wxT("tiles"), m_tsize);\r
+ OPJconfig->Write(wxT("torigin"), m_torigin);\r
+ OPJconfig->Write(wxT("enablesop"), m_enablesop);\r
+ OPJconfig->Write(wxT("enableeph"), m_enableeph);\r
+ OPJconfig->Write(wxT("enableidx"), m_enableidx);\r
+ OPJconfig->Write(wxT("index"), m_index);\r
+ OPJconfig->Write(wxT("enablecomm"), m_enablecomm);\r
+ OPJconfig->Write(wxT("comment"), m_comment);\r
+\r
#endif // OPJ_INICONFIG\r
\r
return 1;\r
BEGIN_EVENT_TABLE(OPJFrame, wxMDIParentFrame)\r
EVT_MENU(OPJFRAME_HELPABOUT, OPJFrame::OnAbout)\r
EVT_MENU(OPJFRAME_FILEOPEN, OPJFrame::OnFileOpen)\r
+ EVT_MENU(OPJFRAME_FILESAVEAS, OPJFrame::OnFileSaveAs)\r
+ EVT_MENU(OPJFRAME_MEMORYOPEN, OPJFrame::OnMemoryOpen)\r
EVT_SIZE(OPJFrame::OnSize)\r
EVT_MENU(OPJFRAME_FILEEXIT, OPJFrame::OnQuit)\r
EVT_MENU(OPJFRAME_FILECLOSE, OPJFrame::OnClose)\r
file_menu->Append(OPJFRAME_FILEOPEN, wxT("&Open\tCtrl+O"));\r
file_menu->SetHelpString(OPJFRAME_FILEOPEN, wxT("Open one or more files"));\r
\r
+ file_menu->Append(OPJFRAME_MEMORYOPEN, wxT("&Memory\tCtrl+M"));\r
+ file_menu->SetHelpString(OPJFRAME_MEMORYOPEN, wxT("Open a memory buffer"));\r
+\r
+ file_menu->Append(OPJFRAME_FILECLOSE, wxT("&Close\tCtrl+C"));\r
+ file_menu->SetHelpString(OPJFRAME_FILECLOSE, wxT("Close current image"));\r
+\r
+ file_menu->AppendSeparator();\r
+\r
file_menu->Append(OPJFRAME_FILESAVEAS, wxT("&Save as\tCtrl+S"));\r
file_menu->SetHelpString(OPJFRAME_FILESAVEAS, wxT("Save the current image"));\r
- file_menu->Enable(OPJFRAME_FILESAVEAS, false);\r
+ //file_menu->Enable(OPJFRAME_FILESAVEAS, false);\r
+\r
+ file_menu->AppendSeparator();\r
\r
file_menu->Append(OPJFRAME_FILETOGGLEB, wxT("Toggle &browser\tCtrl+B"));\r
file_menu->SetHelpString(OPJFRAME_FILETOGGLEB, wxT("Toggle the left browsing pane"));\r
file_menu->Append(OPJFRAME_FILETOGGLET, wxT("Toggle &toolbar\tCtrl+T"));\r
file_menu->SetHelpString(OPJFRAME_FILETOGGLET, wxT("Toggle the toolbar"));\r
\r
- file_menu->Append(OPJFRAME_FILECLOSE, wxT("&Close\tCtrl+C"));\r
- file_menu->SetHelpString(OPJFRAME_FILECLOSE, wxT("Close current image"));\r
+ file_menu->AppendSeparator();\r
\r
file_menu->Append(OPJFRAME_FILEEXIT, wxT("&Exit\tCtrl+Q"));\r
file_menu->SetHelpString(OPJFRAME_FILEEXIT, wxT("Quit this program"));\r
\r
tool_bar->AddTool(OPJFRAME_FILEOPEN, bmpOpen, wxT("Open"));\r
tool_bar->AddTool(OPJFRAME_FILESAVEAS, bmpSaveAs, wxT("Save as "));\r
- tool_bar->EnableTool(OPJFRAME_FILESAVEAS, false);\r
+ //tool_bar->EnableTool(OPJFRAME_FILESAVEAS, false);\r
tool_bar->AddSeparator();\r
tool_bar->AddTool(OPJFRAME_VIEWZOOM, bmpZoom, wxT("Zoom"));\r
tool_bar->AddTool(OPJFRAME_VIEWFIT, bmpFit, wxT("Zoom to fit"));\r
\r
if (dialog.ShowModal() == wxID_OK) {\r
\r
+ // load settings\r
+ wxGetApp().m_subsampling = dialog.m_subsamplingCtrl->GetValue();\r
+ wxGetApp().m_origin = dialog.m_originCtrl->GetValue();\r
+ wxGetApp().m_rates = dialog.m_rateCtrl->GetValue();\r
+ wxGetApp().m_quality = dialog.m_qualityCtrl->GetValue();\r
+ wxGetApp().m_irreversible = dialog.m_irrevCheck->GetValue();\r
+ wxGetApp().m_resolutions = dialog.m_resolutionsCtrl->GetValue();\r
+ wxGetApp().m_cbsize = dialog.m_cbsizeCtrl->GetValue();\r
+ wxGetApp().m_prsize = dialog.m_prsizeCtrl->GetValue();\r
+ wxGetApp().m_tsize = dialog.m_tsizeCtrl->GetValue();\r
+ wxGetApp().m_torigin = dialog.m_toriginCtrl->GetValue();\r
+ wxGetApp().m_enablesop = dialog.m_sopCheck->GetValue();\r
+ wxGetApp().m_enableeph = dialog.m_ephCheck->GetValue();\r
+ wxGetApp().m_enableidx = dialog.m_enableidxCheck->GetValue();\r
+ wxGetApp().m_index = dialog.m_indexCtrl->GetValue();\r
+ wxGetApp().m_enablecomm = dialog.m_enablecommCheck->GetValue();\r
+ wxGetApp().m_comment = dialog.m_commentCtrl->GetValue();\r
};\r
}\r
\r
\r
}\r
\r
+// physically save the file\r
+void OPJFrame::SaveFile(wxArrayString paths, wxArrayString filenames)\r
+{\r
+ size_t count = paths.GetCount();\r
+ wxString msg, s;\r
+\r
+ if (wxFile::Exists(paths[0].c_str())) {\r
+\r
+ s.Printf(wxT("File %s already exists. Do you want to overwrite it?\n"), filenames[0].c_str());\r
+ wxMessageDialog dialog3(this, s, _T("File exists"), wxYES_NO);\r
+ if (dialog3.ShowModal() == wxID_NO)\r
+ return;\r
+ }\r
+\r
+ /*s.Printf(_T("File %d: %s (%s)\n"), (int)0, paths[0].c_str(), filenames[0].c_str());\r
+ msg += s;\r
+\r
+ wxMessageDialog dialog2(this, msg, _T("Selected files"));\r
+ dialog2.ShowModal();*/\r
+\r
+ if (!GetActiveChild())\r
+ return;\r
+\r
+ ((OPJChildFrame *) GetActiveChild())->m_canvas->m_savename = paths[0];\r
+\r
+ OPJEncoThread *ethread = ((OPJChildFrame *) GetActiveChild())->m_canvas->CreateEncoThread();\r
+\r
+ if (ethread->Run() != wxTHREAD_NO_ERROR)\r
+ wxLogMessage(wxT("Can't start enco thread!"));\r
+ else\r
+ wxLogMessage(wxT("New enco thread started."));\r
+\r
+\r
+}\r
+\r
// physically open the files\r
void OPJFrame::OpenFiles(wxArrayString paths, wxArrayString filenames)\r
{\r
\r
}\r
\r
+void OPJFrame::OnFileSaveAs(wxCommandEvent& WXUNUSED(event))\r
+{\r
+ wxString wildcards =\r
+#ifdef wxUSE_LIBOPENJPEG\r
+#ifdef __WXMOTIF__\r
+ wxT("JPEG 2000 codestream (*.j2k)|*.*j*2*");\r
+#else\r
+ wxT("JPEG 2000 codestream (*.j2k)|*.j2k")\r
+ wxT("|JPEG 2000 file format (*.jp2)|*.jp2");\r
+#endif\r
+#endif\r
+\r
+ wxFileDialog dialog(this, _T("Save image file"),\r
+ wxEmptyString, wxEmptyString, wildcards,\r
+ wxFD_SAVE);\r
+\r
+ if (dialog.ShowModal() == wxID_OK) {\r
+ wxArrayString paths, filenames;\r
+\r
+ dialog.GetPaths(paths);\r
+ dialog.GetFilenames(filenames);\r
+\r
+ SaveFile(paths, filenames);\r
+ }\r
+\r
+\r
+}\r
+\r
+void OPJFrame::OnMemoryOpen(wxCommandEvent& WXUNUSED(event))\r
+{\r
+ wxTextEntryDialog dialog(this, wxT("Memory HEX address range: start_address-stop_address"),\r
+ wxT("Decode a memory buffer"),\r
+ wxT("0x-0x"),\r
+ wxOK | wxCANCEL | wxCENTRE,\r
+ wxDefaultPosition);\r
+\r
+ if (dialog.ShowModal() == wxID_OK) {\r
+\r
+ }\r
+\r
+}\r
+\r
BEGIN_EVENT_TABLE(OPJCanvas, wxScrolledWindow)\r
EVT_MOUSE_EVENTS(OPJCanvas::OnEvent)\r
END_EVENT_TABLE()\r
return dthread;\r
}\r
\r
+OPJEncoThread *OPJCanvas::CreateEncoThread(void)\r
+{\r
+ OPJEncoThread *ethread = new OPJEncoThread(this);\r
+\r
+ if (ethread->Create() != wxTHREAD_NO_ERROR)\r
+ wxLogError(wxT("Can't create enco thread!"));\r
+\r
+ wxCriticalSectionLocker enter(wxGetApp().m_enco_critsect);\r
+ wxGetApp().m_enco_threads.Add(ethread);\r
+\r
+ return ethread;\r
+}\r
+\r
#define activeoverlay 0\r
// Define the repainting behaviour\r
void OPJCanvas::OnDraw(wxDC& dc)\r
unsigned(tree->GetChildrenCount(GetId(), false)));\r
}\r
\r
+/////////////////////////////////////////////////////////////////////\r
+// Encoding thread class\r
+/////////////////////////////////////////////////////////////////////\r
+\r
+OPJEncoThread::OPJEncoThread(OPJCanvas *canvas)\r
+ : wxThread()\r
+{\r
+ m_count = 0;\r
+ m_canvas = canvas;\r
+}\r
+\r
+void OPJEncoThread::WriteText(const wxString& text)\r
+{\r
+ wxString msg;\r
+\r
+ // before doing any GUI calls we must ensure that this thread is the only\r
+ // one doing it!\r
+\r
+#ifndef __WXGTK__ \r
+ wxMutexGuiEnter();\r
+#endif // __WXGTK__\r
+\r
+ msg << text;\r
+ m_canvas->WriteText(msg);\r
+\r
+#ifndef __WXGTK__ \r
+ wxMutexGuiLeave();\r
+#endif // __WXGTK__\r
+}\r
+\r
+void OPJEncoThread::OnExit()\r
+{\r
+ wxCriticalSectionLocker locker(wxGetApp().m_enco_critsect);\r
+\r
+ wxArrayThread& ethreads = wxGetApp().m_enco_threads;\r
+ ethreads.Remove(this);\r
+\r
+ if (ethreads.IsEmpty() )\r
+ {\r
+ // signal the main thread that there are no more threads left if it is\r
+ // waiting for us\r
+ if (wxGetApp().m_enco_waitingUntilAllDone) {\r
+ wxGetApp().m_enco_waitingUntilAllDone = false;\r
+ wxGetApp().m_enco_semAllDone.Post();\r
+ }\r
+ }\r
+}\r
+\r
+void *OPJEncoThread::Entry()\r
+{\r
+ wxString text;\r
+\r
+ srand(GetId());\r
+ //int m_countnum = rand() % 9;\r
+ //text.Printf(wxT("Deco thread 0x%lx started (priority = %u, time = %d)."),\r
+ // GetId(), GetPriority(), m_countnum);\r
+ text.Printf(wxT("Enco thread %d started"), m_canvas->m_childframe->m_winnumber);\r
+ WriteText(text);\r
+\r
+ // set handler properties\r
+ wxJ2KHandler *j2kkkhandler = (wxJ2KHandler *) wxImage::FindHandler( wxBITMAP_TYPE_J2K);\r
+ j2kkkhandler->m_subsampling = wxGetApp().m_subsampling;\r
+ j2kkkhandler->m_origin = wxGetApp().m_origin;\r
+ j2kkkhandler->m_rates = wxGetApp().m_rates;\r
+ j2kkkhandler->m_quality = wxGetApp().m_quality;\r
+ j2kkkhandler->m_irreversible = wxGetApp().m_irreversible;\r
+ j2kkkhandler->m_resolutions = wxGetApp().m_resolutions;\r
+ j2kkkhandler->m_cbsize = wxGetApp().m_cbsize;\r
+ j2kkkhandler->m_prsize = wxGetApp().m_prsize;\r
+ j2kkkhandler->m_tsize = wxGetApp().m_tsize;\r
+ j2kkkhandler->m_torigin = wxGetApp().m_torigin;\r
+ j2kkkhandler->m_enablesop = wxGetApp().m_enablesop;\r
+ j2kkkhandler->m_enableeph = wxGetApp().m_enableeph;\r
+ j2kkkhandler->m_enableidx = wxGetApp().m_enableidx;\r
+ j2kkkhandler->m_index = m_canvas->m_savename.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + wxGetApp().m_index;\r
+ j2kkkhandler->m_enablecomm = wxGetApp().m_enablecomm;\r
+ j2kkkhandler->m_comment = wxGetApp().m_comment;\r
+\r
+ // save the file\r
+ if (!m_canvas->m_image100.SaveFile(m_canvas->m_savename.GetFullPath(), wxBITMAP_TYPE_J2K)) {\r
+ WriteText(wxT("Can't save image"));\r
+ return NULL;\r
+ }\r
+\r
+ text.Printf(wxT("Enco thread %d finished"), m_canvas->m_childframe->m_winnumber);\r
+ WriteText(text);\r
+ return NULL;\r
+}\r
+\r
/////////////////////////////////////////////////////////////////////\r
// Decoding thread class\r
/////////////////////////////////////////////////////////////////////\r
BEGIN_EVENT_TABLE(OPJEncoderDialog, wxPropertySheetDialog)\r
#ifdef USE_JPWL\r
EVT_CHECKBOX(OPJENCO_ENABLEJPWL, OPJEncoderDialog::OnEnableJPWL)\r
+ EVT_CHECKBOX(OPJENCO_ENABLECOMM, OPJEncoderDialog::OnEnableComm)\r
+ EVT_CHECKBOX(OPJENCO_ENABLEINDEX, OPJEncoderDialog::OnEnableIdx)\r
#endif // USE_JPWL\r
END_EVENT_TABLE()\r
\r
\r
m_settingsNotebook = GetBookCtrl();\r
\r
- wxPanel* mainSettings = CreateMainSettingsPage(m_settingsNotebook);\r
wxPanel* jpeg2000Settings = CreatePart1SettingsPage(m_settingsNotebook);\r
-/* if (!wxGetApp().m_enabledeco)\r
- jpeg2000Settings->Enable(false);\r
- wxPanel* mjpeg2000Settings = CreatePart3SettingsPage(m_settingsNotebook);\r
- if (!wxGetApp().m_enabledeco)\r
- mjpeg2000Settings->Enable(false);\r
-#ifdef USE_JPWL\r
- wxPanel* jpwlSettings = CreatePart11SettingsPage(m_settingsNotebook);\r
- if (!wxGetApp().m_enabledeco)\r
- jpwlSettings->Enable(false);\r
-#endif // USE_JPWL\r
-*/\r
+ wxPanel* mainSettings = CreateMainSettingsPage(m_settingsNotebook);\r
\r
- m_settingsNotebook->AddPage(mainSettings, wxT("General"), false);\r
m_settingsNotebook->AddPage(jpeg2000Settings, wxT("JPEG 2000"), false);\r
-/* m_settingsNotebook->AddPage(mjpeg2000Settings, wxT("MJPEG 2000"), false);\r
-#ifdef USE_JPWL\r
- m_settingsNotebook->AddPage(jpwlSettings, wxT("JPWL"), false);\r
-#endif // USE_JPWL\r
-*/\r
+ m_settingsNotebook->AddPage(mainSettings, wxT("General"), false);\r
+\r
LayoutDialog();\r
}\r
\r
//topSizer->AddSpacer(5);\r
\r
// sub top sizer\r
- wxFlexGridSizer *subtopSizer = new wxFlexGridSizer(2, 3, 3);\r
+ wxFlexGridSizer *subtopSizer = new wxFlexGridSizer(4, 3, 3);\r
\r
// image settings, column\r
wxStaticBox* imageBox = new wxStaticBox(panel, wxID_ANY, wxT("Image"));\r
\r
// add the value control\r
subsSizer->Add(\r
- /*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_SUBSAMPLING,\r
- wxT("1,1"),\r
+ m_subsamplingCtrl = new wxTextCtrl(panel, OPJENCO_SUBSAMPLING,\r
+ wxGetApp().m_subsampling,\r
wxDefaultPosition, wxSize(120, wxDefaultCoord),\r
wxTE_LEFT),\r
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);\r
\r
// add the value control\r
imorigSizer->Add(\r
- /*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_IMORIG,\r
- wxT("0,0"),\r
+ m_originCtrl = new wxTextCtrl(panel, OPJENCO_IMORIG,\r
+ wxGetApp().m_origin,\r
wxDefaultPosition, wxSize(120, wxDefaultCoord),\r
wxTE_LEFT),\r
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);\r
subtopSizer->Add(imageSizer, 0, wxGROW | wxALL, 3);\r
\r
// layer settings, column\r
- wxStaticBox* layerBox = new wxStaticBox(panel, wxID_ANY, wxT("Layers"));\r
+ wxStaticBox* layerBox = new wxStaticBox(panel, wxID_ANY, wxT("Layers/compression"));\r
wxBoxSizer* layerSizer = new wxStaticBoxSizer(layerBox, wxVERTICAL);\r
\r
// rate factor sizer, row\r
\r
// add the value control\r
rateSizer->Add(\r
- /*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_RATEFACTOR,\r
- wxT("20,10,5"),\r
+ m_rateCtrl = new wxTextCtrl(panel, OPJENCO_RATEFACTOR,\r
+ wxGetApp().m_rates,\r
wxDefaultPosition, wxSize(120, wxDefaultCoord),\r
wxTE_LEFT),\r
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);\r
\r
// add the value control\r
qualitySizer->Add(\r
- /*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_QUALITYFACTOR,\r
- wxT("30,35,40"),\r
+ m_qualityCtrl = new wxTextCtrl(panel, OPJENCO_QUALITYFACTOR,\r
+ wxGetApp().m_quality,\r
wxDefaultPosition, wxSize(120, wxDefaultCoord),\r
wxTE_LEFT),\r
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);\r
subtopSizer->Add(layerSizer, 0, wxGROW | wxALL, 3);\r
\r
// wavelet settings, column\r
- wxStaticBox* waveletBox = new wxStaticBox(panel, wxID_ANY, wxT("Transform"));\r
+ wxStaticBox* waveletBox = new wxStaticBox(panel, wxID_ANY, wxT("Wavelet transform"));\r
wxBoxSizer* waveletSizer = new wxStaticBoxSizer(waveletBox, wxVERTICAL);\r
\r
// irreversible check box\r
waveletSizer->Add(\r
- /*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLEIRREV, wxT("Irreversible"),\r
+ m_irrevCheck = new wxCheckBox(panel, OPJENCO_ENABLEIRREV, wxT("Irreversible"),\r
wxDefaultPosition, wxDefaultSize),\r
0, wxGROW | wxALL, 3);\r
- /*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/\r
+ m_irrevCheck->SetValue(wxGetApp().m_irreversible);\r
\r
// resolution number sizer, row\r
wxBoxSizer* resnumSizer = new wxBoxSizer(wxHORIZONTAL);\r
\r
// add the value control\r
resnumSizer->Add(\r
- /*m_layerCtrl =*/ new wxSpinCtrl(panel, OPJENCO_RESNUMBER,\r
- wxT("6"),\r
+ m_resolutionsCtrl = new wxSpinCtrl(panel, OPJENCO_RESNUMBER,\r
+ wxString::Format("%d", wxGetApp().m_resolutions),\r
wxDefaultPosition, wxSize(80, wxDefaultCoord),\r
wxSP_ARROW_KEYS,\r
0, 256, 6),\r
\r
waveletSizer->Add(resnumSizer, 0, wxGROW | wxALL, 3);\r
\r
+ subtopSizer->Add(waveletSizer, 0, wxGROW | wxALL, 3);\r
+\r
+ // codestream settings, column\r
+ wxStaticBox* codestreamBox = new wxStaticBox(panel, wxID_ANY, wxT("Codestream"));\r
+ wxBoxSizer* codestreamSizer = new wxStaticBoxSizer(codestreamBox, wxVERTICAL);\r
+\r
// codeblock sizer, row\r
wxBoxSizer* codeblockSizer = new wxBoxSizer(wxHORIZONTAL);\r
\r
\r
// add the value control\r
codeblockSizer->Add(\r
- /*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_CODEBLOCKSIZE,\r
- wxT("32,32"),\r
+ m_cbsizeCtrl = new wxTextCtrl(panel, OPJENCO_CODEBLOCKSIZE,\r
+ wxGetApp().m_cbsize,\r
wxDefaultPosition, wxSize(120, wxDefaultCoord),\r
wxTE_LEFT),\r
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);\r
\r
- waveletSizer->Add(codeblockSizer, 0, wxGROW | wxALL, 3);\r
+ codestreamSizer->Add(codeblockSizer, 0, wxGROW | wxALL, 3);\r
\r
// precinct sizer, row\r
wxBoxSizer* precinctSizer = new wxBoxSizer(wxHORIZONTAL);\r
\r
// add the value control\r
precinctSizer->Add(\r
- /*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_PRECINCTSIZE,\r
- wxT("[128,128],[128,128]"),\r
+ m_prsizeCtrl = new wxTextCtrl(panel, OPJENCO_PRECINCTSIZE,\r
+ wxGetApp().m_prsize,\r
wxDefaultPosition, wxSize(120, wxDefaultCoord),\r
wxTE_LEFT),\r
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);\r
\r
- waveletSizer->Add(precinctSizer, 0, wxGROW | wxALL, 3);\r
+ codestreamSizer->Add(precinctSizer, 0, wxGROW | wxALL, 3);\r
\r
- subtopSizer->Add(waveletSizer, 0, wxGROW | wxALL, 3);\r
+ subtopSizer->Add(codestreamSizer, 0, wxGROW | wxALL, 3);\r
\r
// tile settings, column\r
wxStaticBox* tileBox = new wxStaticBox(panel, wxID_ANY, wxT("Tiles"));\r
\r
// add the value control\r
tilesizeSizer->Add(\r
- /*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_TILESIZE,\r
- wxT(""),\r
+ m_tsizeCtrl = new wxTextCtrl(panel, OPJENCO_TILESIZE,\r
+ wxGetApp().m_tsize,\r
wxDefaultPosition, wxSize(120, wxDefaultCoord),\r
wxTE_LEFT),\r
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);\r
\r
// add the value control\r
tilorigSizer->Add(\r
- /*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_TILORIG,\r
- wxT("0,0"),\r
+ m_toriginCtrl = new wxTextCtrl(panel, OPJENCO_TILORIG,\r
+ wxGetApp().m_torigin,\r
wxDefaultPosition, wxSize(120, wxDefaultCoord),\r
wxTE_LEFT),\r
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);\r
// progression settings, column\r
wxString choices[] = {wxT("LRCP"), wxT("RLCP"), wxT("RPCL"), wxT("PCRL"), wxT("CPRL")};\r
wxRadioBox *progressionBox = new wxRadioBox(panel, OPJENCO_PROGRESSION,\r
- wxT("Progression"),\r
+ wxT("Progression order"),\r
wxDefaultPosition, wxDefaultSize,\r
WXSIZEOF(choices),\r
choices,\r
subtopSizer->Add(progressionBox, 0, wxGROW | wxALL, 3);\r
\r
// resilience settings, column\r
- wxStaticBox* resilBox = new wxStaticBox(panel, wxID_ANY, wxT("Resilience"));\r
+ wxStaticBox* resilBox = new wxStaticBox(panel, wxID_ANY, wxT("Error resilience"));\r
wxBoxSizer* resilSizer = new wxStaticBoxSizer(resilBox, wxVERTICAL);\r
\r
// resil2 sizer, row\r
\r
// SOP check box\r
resil2Sizer->Add(\r
- /*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLESOP, wxT("SOP"),\r
- wxDefaultPosition, wxDefaultSize),\r
- 0, wxGROW | wxALL, 3);\r
- /*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/\r
+ m_sopCheck = new wxCheckBox(panel, OPJENCO_ENABLESOP, wxT("SOP"),\r
+ wxDefaultPosition, wxDefaultSize),\r
+ 0, wxGROW | wxALL, 3);\r
+ m_sopCheck->SetValue(wxGetApp().m_enablesop);\r
\r
// EPH check box\r
resil2Sizer->Add(\r
- /*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLEEPH, wxT("EPH"),\r
- wxDefaultPosition, wxDefaultSize),\r
- 0, wxGROW | wxALL, 3);\r
- /*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/\r
+ m_ephCheck = new wxCheckBox(panel, OPJENCO_ENABLEEPH, wxT("EPH"),\r
+ wxDefaultPosition, wxDefaultSize),\r
+ 0, wxGROW | wxALL, 3);\r
+ m_ephCheck->SetValue(wxGetApp().m_enableeph);\r
\r
resilSizer->Add(resil2Sizer, 0, wxGROW | wxALL, 3);\r
\r
subtopSizer->Add(resilSizer, 0, wxGROW | wxALL, 3);\r
\r
// ROI settings, column\r
- wxStaticBox* roiBox = new wxStaticBox(panel, wxID_ANY, wxT("ROI"));\r
+ wxStaticBox* roiBox = new wxStaticBox(panel, wxID_ANY, wxT("Region Of Interest"));\r
wxBoxSizer* roiSizer = new wxStaticBoxSizer(roiBox, wxVERTICAL);\r
\r
// component number sizer, row\r
\r
// indexing check box\r
indexSizer->Add(\r
- /*m_enabledecoCheck =*/ new wxCheckBox(panel, OPJENCO_ENABLEINDEX, wxT("Enabled"),\r
+ m_enableidxCheck = new wxCheckBox(panel, OPJENCO_ENABLEINDEX, wxT("Enabled"),\r
wxDefaultPosition, wxDefaultSize),\r
0, wxGROW | wxALL, 3);\r
- /*m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);*/\r
+ m_enableidxCheck->SetValue(wxGetApp().m_enableidx);\r
\r
// index file sizer, row\r
wxBoxSizer* indexnameSizer = new wxBoxSizer(wxHORIZONTAL);\r
\r
// add the value control\r
indexnameSizer->Add(\r
- /*m_rateCtrl = */new wxTextCtrl(panel, OPJENCO_INDEXNAME,\r
- wxT(""),\r
+ m_indexCtrl = new wxTextCtrl(panel, OPJENCO_INDEXNAME,\r
+ wxGetApp().m_index,\r
wxDefaultPosition, wxSize(120, wxDefaultCoord),\r
wxTE_LEFT),\r
0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);\r
+ m_indexCtrl->Enable(wxGetApp().m_enableidx);\r
\r
indexSizer->Add(indexnameSizer, 0, wxGROW | wxALL, 3);\r
\r
subtopSizer->Add(indexSizer, 0, wxGROW | wxALL, 3);\r
\r
-/* // component settings, column\r
- wxStaticBox* compoBox = new wxStaticBox(panel, wxID_ANY, wxT("Components"));\r
- wxBoxSizer* compoSizer = new wxStaticBoxSizer(compoBox, wxVERTICAL);\r
-\r
- // quality layers sizer, row\r
- wxBoxSizer* numcompsSizer = new wxBoxSizer(wxHORIZONTAL);\r
+ // Comment settings, column\r
+ wxStaticBox* commentBox = new wxStaticBox(panel, wxID_ANY, wxT("Comment"));\r
+ wxBoxSizer* commentSizer = new wxStaticBoxSizer(commentBox, wxVERTICAL);\r
\r
- // add some text\r
- numcompsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Component displayed:")),\r
- 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);\r
+ // commenting check box\r
+ commentSizer->Add(\r
+ m_enablecommCheck = new wxCheckBox(panel, OPJENCO_ENABLECOMM, wxT("Enabled"),\r
+ wxDefaultPosition, wxDefaultSize),\r
+ 0, wxGROW | wxALL, 3);\r
+ m_enablecommCheck->SetValue(wxGetApp().m_enablecomm);\r
\r
- // add some horizontal space\r
- numcompsSizer->Add(5, 5, 1, wxALL, 0);\r
+ // add some horizontal space\r
+ commentSizer->Add(3, 3, 1, wxALL, 0);\r
\r
- // add the value control\r
- numcompsSizer->Add(\r
- m_numcompsCtrl = new wxSpinCtrl(panel, OPJDECO_NUMCOMPS,\r
- wxString::Format(wxT("%d"), wxGetApp().m_components),\r
- wxDefaultPosition, wxSize(80, wxDefaultCoord),\r
- wxSP_ARROW_KEYS,\r
- 0, 100000, wxGetApp().m_components),\r
- 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);\r
- m_numcompsCtrl->Enable(true);\r
+ // add the value control\r
+ commentSizer->Add(\r
+ m_commentCtrl = new wxTextCtrl(panel, OPJENCO_COMMENTTEXT,\r
+ wxGetApp().m_comment,\r
+ wxDefaultPosition, wxSize(wxDefaultCoord, 60),\r
+ wxTE_LEFT | wxTE_MULTILINE),\r
+ 0, wxGROW | wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);\r
+ m_commentCtrl->Enable(wxGetApp().m_enablecomm);\r
\r
- compoSizer->Add(numcompsSizer, 0, wxGROW | wxALL, 5);\r
+ subtopSizer->Add(commentSizer, 0, wxGROW | wxALL, 3);\r
\r
- subtopSizer->Add(compoSizer, 0, wxGROW | wxALL, 5);\r
-*/\r
topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5);\r
\r
// assign top and fit it\r
return panel;\r
}\r
\r
+void OPJEncoderDialog::OnEnableComm(wxCommandEvent& event)\r
+{\r
+ if (event.IsChecked()) {\r
+ wxLogMessage(wxT("Comment enabled"));\r
+ m_commentCtrl->Enable(true);\r
+ } else {\r
+ wxLogMessage(wxT("Comment disabled"));\r
+ m_commentCtrl->Enable(false);\r
+ }\r
+\r
+}\r
+\r
+void OPJEncoderDialog::OnEnableIdx(wxCommandEvent& event)\r
+{\r
+ if (event.IsChecked()) {\r
+ wxLogMessage(wxT("Index enabled"));\r
+ m_indexCtrl->Enable(true);\r
+ } else {\r
+ wxLogMessage(wxT("Index disabled"));\r
+ m_indexCtrl->Enable(false);\r
+ }\r
+}\r
+\r
#ifdef USE_JPWL\r
void OPJEncoderDialog::OnEnableJPWL(wxCommandEvent& event)\r
{\r
}\r
\r
// save the j2k codestream\r
-bool wxJ2KHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbose )\r
+bool wxJ2KHandler::SaveFile( wxImage *wimage, wxOutputStream& stream, bool verbose )\r
{\r
+ opj_cparameters_t parameters; /* compression parameters */\r
+ opj_event_mgr_t event_mgr; /* event manager */\r
+ opj_image_t *oimage = NULL;\r
+ opj_image_cmptparm_t *cmptparm; \r
+ opj_cio_t *cio = NULL;\r
+ int codestream_length;\r
+ bool bSuccess;\r
+ int i;\r
+\r
+ /*\r
+ configure the event callbacks (not required)\r
+ setting of each callback is optionnal\r
+ */\r
+ memset(&event_mgr, 0, sizeof(opj_event_mgr_t));\r
+ event_mgr.error_handler = j2k_error_callback;\r
+ event_mgr.warning_handler = j2k_warning_callback;\r
+ event_mgr.info_handler = j2k_info_callback;\r
+\r
+ /* set encoding parameters to default values */\r
+ opj_set_default_encoder_parameters(¶meters);\r
+\r
+ /* load parameters */\r
+\r
+ /* subsampling */\r
+ if (sscanf(m_subsampling.c_str(), wxT("%d,%d"), &(parameters.subsampling_dx), &(parameters.subsampling_dy)) != 2) {\r
+ wxLogError(wxT("Wrong sub-sampling encoder setting: dx,dy"));\r
+ return false;\r
+ }\r
+\r
+ /* compression rates */\r
+ if (m_rates != wxT("")) {\r
+ char *s1 = (char *) m_rates.c_str();\r
+ wxLogMessage("rates %s", s1);\r
+ while (sscanf(s1, "%f", &(parameters.tcp_rates[parameters.tcp_numlayers])) == 1) {\r
+ parameters.tcp_numlayers++;\r
+ while (*s1 && *s1 != ',') {\r
+ s1++;\r
+ }\r
+ if (!*s1)\r
+ break;\r
+ s1++;\r
+ }\r
+ wxLogMessage("%d layers", parameters.tcp_numlayers);\r
+ parameters.cp_disto_alloc = 1;\r
+ }\r
+\r
+ /* image quality, dB */\r
+ if (m_rates == wxT("")) {\r
+ char *s2 = (char *) m_quality.c_str();\r
+ wxLogMessage("qualities %s", s2);\r
+ while (sscanf(s2, "%f", ¶meters.tcp_distoratio[parameters.tcp_numlayers]) == 1) {\r
+ parameters.tcp_numlayers++;\r
+ while (*s2 && *s2 != ',') {\r
+ s2++;\r
+ }\r
+ if (!*s2)\r
+ break;\r
+ s2++;\r
+ }\r
+ wxLogMessage("%d layers", parameters.tcp_numlayers);\r
+ parameters.cp_fixed_quality = 1;\r
+ }\r
+\r
+ /* image origin */\r
+ if (sscanf(m_origin.c_str(), "%d,%d", ¶meters.image_offset_x0, ¶meters.image_offset_y0) != 2) {\r
+ wxLogError(wxT("bad coordinate of the image origin: x0,y0"));\r
+ return false;\r
+ }\r
+ \r
+ /* Create comment for codestream */\r
+ if(m_enablecomm) {\r
+ parameters.cp_comment = (char *) malloc(strlen(m_comment.c_str()) + 1);\r
+ if(parameters.cp_comment) {\r
+ strcpy(parameters.cp_comment, m_comment.c_str());\r
+ }\r
+ } else {\r
+ parameters.cp_comment = NULL;\r
+ }\r
+\r
+ /* indexing file */\r
+ if (m_enableidx) {\r
+ strncpy(parameters.index, m_index.c_str(), m_index.Len());\r
+ wxLogMessage("index file is %s", parameters.index);\r
+ parameters.index_on = 1;\r
+ } else {\r
+ parameters.index_on = 0;\r
+ }\r
+\r
+ /* if no rate entered, lossless by default */\r
+ if (parameters.tcp_numlayers == 0) {\r
+ parameters.tcp_rates[0] = 0; /* MOD antonin : losslessbug */\r
+ parameters.tcp_numlayers++;\r
+ parameters.cp_disto_alloc = 1;\r
+ }\r
+\r
+ /* irreversible transform */\r
+ parameters.irreversible = (m_irreversible == true) ? 1 : 0;\r
+\r
+ /* resolutions */\r
+ parameters.numresolution = m_resolutions;\r
+\r
+ /* codeblocks size */\r
+ if (m_cbsize != wxT("")) {\r
+ int cblockw_init = 0, cblockh_init = 0;\r
+ sscanf(m_cbsize.c_str(), "%d,%d", &cblockw_init, &cblockh_init);\r
+ if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024 || cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {\r
+ wxLogError("!! Size of code_block error !! Restrictions:\n width*height<=4096\n 4<=width,height<= 1024");\r
+ return false;\r
+ }\r
+ parameters.cblockw_init = cblockw_init;\r
+ parameters.cblockh_init = cblockh_init;\r
+ }\r
+\r
+ /* precincts size */\r
+ if (m_prsize != wxT("")) {\r
+ char sep;\r
+ int res_spec = 0;\r
+ char *s = (char *) m_prsize.c_str();\r
+ do {\r
+ sep = 0;\r
+ sscanf(s, "[%d,%d]%c", ¶meters.prcw_init[res_spec], ¶meters.prch_init[res_spec], &sep);\r
+ parameters.csty |= 0x01;\r
+ res_spec++;\r
+ s = strpbrk(s, "]") + 2;\r
+ } while (sep == ',');\r
+ parameters.res_spec = res_spec;\r
+ }\r
+\r
+ /* tiles */\r
+ if (m_tsize != wxT("")) {\r
+ sscanf(m_tsize.c_str(), "%d,%d", ¶meters.cp_tdx, ¶meters.cp_tdy);\r
+ parameters.tile_size_on = true;\r
+ }\r
+\r
+ /* tile origin */\r
+ if (sscanf(m_torigin.c_str(), "%d,%d", ¶meters.cp_tx0, ¶meters.cp_ty0) != 2) {\r
+ wxLogError("tile offset setting error: X0,Y0");\r
+ return false;\r
+ }\r
+\r
+ /* use SOP */\r
+ if (m_enablesop)\r
+ parameters.csty |= 0x02;\r
+\r
+ /* use EPH */\r
+ if (m_enableeph)\r
+ parameters.csty |= 0x04;\r
+\r
+\r
+\r
+ /* compression settings */\r
+ //parameters.tcp_numlayers = 1;\r
+ //parameters.tcp_rates[0] = 10.0;\r
+ //parameters.cp_disto_alloc = 1;\r
+ //parameters.irreversible = 1;\r
+ parameters.tcp_mct = 1;\r
+\r
+ /* convert wx image into opj image */\r
+ cmptparm = (opj_image_cmptparm_t*) malloc(3 * sizeof(opj_image_cmptparm_t));\r
+\r
+ /* initialize opj image components */ \r
+ memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));\r
+ for(i = 0; i < 3; i++) { \r
+ cmptparm[i].prec = 8;\r
+ cmptparm[i].bpp = 8;\r
+ cmptparm[i].sgnd = false;\r
+ cmptparm[i].dx = parameters.subsampling_dx;\r
+ cmptparm[i].dy = parameters.subsampling_dy;\r
+ cmptparm[i].w = wimage->GetWidth();\r
+ cmptparm[i].h = wimage->GetHeight();\r
+ }\r
+\r
+ /* create the image */\r
+ oimage = opj_image_create(3, &cmptparm[0], CLRSPC_SRGB);\r
+ if(!oimage) {\r
+ if (cmptparm)\r
+ free(cmptparm);\r
+ return false;\r
+ }\r
+\r
+ /* set image offset and reference grid */\r
+ oimage->x0 = parameters.image_offset_x0;\r
+ oimage->y0 = parameters.image_offset_y0;\r
+ oimage->x1 = parameters.image_offset_x0 + (wimage->GetWidth() - 1) * 1 + 1;\r
+ oimage->y1 = parameters.image_offset_y0 + (wimage->GetHeight() - 1) * 1 + 1;\r
+\r
+ /* load image data */\r
+ unsigned char *value = wimage->GetData(); \r
+ int area = wimage->GetWidth() * wimage->GetHeight();\r
+ for (i = 0; i < area; i++) {\r
+ oimage->comps[0].data[i] = *(value++);\r
+ oimage->comps[1].data[i] = *(value++);\r
+ oimage->comps[2].data[i] = *(value++);\r
+ }\r
+\r
+ /* get a J2K compressor handle */\r
+ opj_cinfo_t* cinfo = opj_create_compress(CODEC_J2K);\r
+\r
+ /* catch events using our callbacks and give a local context */\r
+ opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);\r
+\r
+ /* setup the encoder parameters using the current image and user parameters */\r
+ opj_setup_encoder(cinfo, ¶meters, oimage);\r
+\r
+ /* open a byte stream for writing */\r
+ /* allocate memory for all tiles */\r
+ cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);\r
+\r
+ /* encode the image */\r
+ bSuccess = opj_encode(cinfo, cio, oimage, parameters.index);\r
+ if (!bSuccess) {\r
+\r
+ opj_cio_close(cio);\r
+ opj_destroy_compress(cinfo);\r
+ opj_image_destroy(oimage);\r
+ if (cmptparm)\r
+ free(cmptparm);\r
+ if(parameters.cp_comment)\r
+ free(parameters.cp_comment);\r
+ if(parameters.cp_matrice)\r
+ free(parameters.cp_matrice);\r
+\r
#ifndef __WXGTK__ \r
wxMutexGuiEnter();\r
#endif /* __WXGTK__ */\r
- wxLogError(wxT("J2K: Couldn't save image -> not implemented."));\r
+\r
+ wxLogError(wxT("failed to encode image"));\r
+\r
+#ifndef __WXGTK__ \r
+ wxMutexGuiLeave();\r
+#endif /* __WXGTK__ */\r
+\r
+ return false;\r
+ }\r
+ codestream_length = cio_tell(cio);\r
+ wxLogMessage(wxT("Codestream: %d bytes"), codestream_length);\r
+\r
+ /* write the buffer to stream */\r
+ stream.Write(cio->buffer, codestream_length);\r
+\r
+ /* close and free the byte stream */\r
+ opj_cio_close(cio);\r
+\r
+ /* free remaining compression structures */\r
+ opj_destroy_compress(cinfo);\r
+\r
+ /* free image data */\r
+ opj_image_destroy(oimage);\r
+\r
+ if (cmptparm)\r
+ free(cmptparm);\r
+ if(parameters.cp_comment)\r
+ free(parameters.cp_comment);\r
+ if(parameters.cp_matrice)\r
+ free(parameters.cp_matrice);\r
+\r
+#ifndef __WXGTK__ \r
+ wxMutexGuiEnter();\r
+#endif /* __WXGTK__ */\r
+\r
+ wxLogMessage(wxT("J2K: Image encoded!"));\r
+\r
#ifndef __WXGTK__ \r
wxMutexGuiLeave();\r
#endif /* __WXGTK__ */\r
\r
- return false;\r
+ return true;\r
}\r
\r
#ifdef __VISUALC__\r
TRAK_BOX,\r
TKHD_BOX,\r
MDIA_BOX,\r
+ MDHD_BOX,\r
+ HDLR_BOX,\r
MINF_BOX,\r
VMHD_BOX,\r
STBL_BOX,\r
#define TRAK_SIGN "trak"\r
#define TKHD_SIGN "tkhd"\r
#define MDIA_SIGN "mdia"\r
+#define MDHD_SIGN "mdhd"\r
+#define HDLR_SIGN "hdlr"\r
#define MINF_SIGN "minf"\r
#define VMHD_SIGN "vmhd"\r
#define STBL_SIGN "stbl"\r
/* req */ {1, 1, 1},\r
/* ins */ TRAK_BOX},\r
\r
+/* sign */ {MDHD_SIGN,\r
+/* short */ "Media Header box",\r
+/* long */ "The media header declares overall information which is media-independent, and relevant to characteristics "\r
+ "of the media in a track",\r
+/* sbox */ 0,\r
+/* req */ {1, 1, 1},\r
+/* ins */ MDIA_BOX},\r
+\r
+/* sign */ {HDLR_SIGN,\r
+/* short */ "Handler Reference box",\r
+/* long */ "This box within a Media Box declares the process by which the media-data in the track may be presented, "\r
+ "and thus, the nature of the media in a track",\r
+/* sbox */ 0,\r
+/* req */ {1, 1, 1},\r
+/* ins */ MDIA_BOX},\r
+\r
/* sign */ {MINF_SIGN,\r
/* short */ "Media Information box",\r
/* long */ "This box contains all the objects which declare characteristic information of the media in the track",\r
};\r
break;\r
\r
+ /* Media Header box */\r
+ case (MDHD_BOX): {\r
+ unsigned long int version;\r
+ unsigned short int language;\r
+ fileid->Read(&version, sizeof(unsigned long int));\r
+ version = BYTE_SWAP4(version);\r
+ if (version == 0) {\r
+ unsigned long int creation_time, modification_time, timescale, duration;\r
+ fileid->Read(&creation_time, sizeof(unsigned long int));\r
+ creation_time = BYTE_SWAP4(creation_time);\r
+ fileid->Read(&modification_time, sizeof(unsigned long int));\r
+ modification_time = BYTE_SWAP4(modification_time);\r
+ fileid->Read(×cale, sizeof(unsigned long int));\r
+ timescale = BYTE_SWAP4(timescale);\r
+ fileid->Read(&duration, sizeof(unsigned long int));\r
+ duration = BYTE_SWAP4(duration);\r
+ const long unix_time = creation_time - 2082844800L;\r
+ wxTreeItemId currid = m_tree->AppendItem(parentid,\r
+ wxString::Format(wxT("Creation time: %u (%.24s)"), creation_time, ctime(&unix_time)),\r
+ m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+ new OPJMarkerData(wxT("INFO"))\r
+ );\r
+ const long unix_time1 = modification_time - 2082844800L;\r
+ currid = m_tree->AppendItem(parentid,\r
+ wxString::Format(wxT("Modification time: %u (%.24s)"), modification_time, ctime(&unix_time1)),\r
+ m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+ new OPJMarkerData(wxT("INFO"))\r
+ );\r
+ currid = m_tree->AppendItem(parentid,\r
+ wxString::Format(wxT("Timescale: %u (%.6fs)"), timescale, 1.0 / (float) timescale),\r
+ m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+ new OPJMarkerData(wxT("INFO"))\r
+ );\r
+ currid = m_tree->AppendItem(parentid,\r
+ wxString::Format(wxT("Duration: %u (%.3fs)"), duration, (float) duration / (float) timescale),\r
+ m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+ new OPJMarkerData(wxT("INFO"))\r
+ );\r
+ } else {\r
+ int8byte creation_time, modification_time, duration;\r
+ unsigned long int timescale;\r
+ fileid->Read(&creation_time, sizeof(int8byte));\r
+ creation_time = BYTE_SWAP8(creation_time);\r
+ fileid->Read(&modification_time, sizeof(int8byte));\r
+ modification_time = BYTE_SWAP8(modification_time);\r
+ fileid->Read(×cale, sizeof(unsigned long int));\r
+ timescale = BYTE_SWAP4(timescale);\r
+ fileid->Read(&duration, sizeof(int8byte));\r
+ duration = BYTE_SWAP8(duration);\r
+ wxTreeItemId currid = m_tree->AppendItem(parentid,\r
+ wxString::Format(wxT("Creation time: %u"), creation_time),\r
+ m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+ new OPJMarkerData(wxT("INFO"))\r
+ );\r
+ currid = m_tree->AppendItem(parentid,\r
+ wxString::Format(wxT("Modification time: %u"), modification_time),\r
+ m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+ new OPJMarkerData(wxT("INFO"))\r
+ );\r
+ currid = m_tree->AppendItem(parentid,\r
+ wxString::Format(wxT("Timescale: %u"), timescale),\r
+ m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+ new OPJMarkerData(wxT("INFO"))\r
+ );\r
+ currid = m_tree->AppendItem(parentid,\r
+ wxString::Format(wxT("Duration: %u"), duration),\r
+ m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+ new OPJMarkerData(wxT("INFO"))\r
+ );\r
+ }\r
+ fileid->Read(&language, sizeof(unsigned short int));\r
+\r
+ wxTreeItemId currid = m_tree->AppendItem(parentid,\r
+ wxString::Format(wxT("Language: %d (%c%c%c)"), language & 0xEFFF,\r
+ 0x60 + (char) ((language >> 10) & 0x001F), 0x60 + (char) ((language >> 5) & 0x001F), 0x60 + (char) ((language >> 0) & 0x001F)),\r
+ m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+ new OPJMarkerData(wxT("INFO"))\r
+ );\r
+ };\r
+ break;\r
\r
+ /* Media Handler box */\r
+ case (HDLR_BOX): {\r
+ unsigned long int version, predefined, temp[3];\r
+ char handler[4], name[256];\r
+ int namelen = wxMin(256, (filelimit - filepoint - 24));\r
+ fileid->Read(&version, sizeof(unsigned long int));\r
+ version = BYTE_SWAP4(version);\r
+ fileid->Read(&predefined, sizeof(unsigned long int));\r
+ fileid->Read(handler, 4 * sizeof(char));\r
+ fileid->Read(&temp, 3 * sizeof(unsigned long int));\r
+ fileid->Read(name, namelen * sizeof(char));\r
+\r
+ wxTreeItemId currid = m_tree->AppendItem(parentid,\r
+ wxString::Format(wxT("Handler: %.4s"), handler),\r
+ m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+ new OPJMarkerData(wxT("INFO"))\r
+ );\r
+ \r
+ currid = m_tree->AppendItem(parentid,\r
+ wxString::Format(wxT("Name: %.255s"), name),\r
+ m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,\r
+ new OPJMarkerData(wxT("INFO"))\r
+ );\r
+ \r
+ }\r
+ break;\r
+\r
/* not yet implemented */\r
default:\r
break;\r