Mercurial > mercurial > hgweb_imcv.cgi
changeset 4:3fadcf124bb4
add Percent.
author | pyon@macmini |
---|---|
date | Tue, 05 Jun 2018 22:09:21 +0900 |
parents | cc1f1fa544a4 |
children | cb33c4b9ea23 |
files | Makefile main.cpp myframe.cpp myframe.h |
diffstat | 4 files changed, 45 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Sun Nov 27 20:15:37 2016 +0900 +++ b/Makefile Tue Jun 05 22:09:21 2018 +0900 @@ -1,5 +1,5 @@ # Makefile for wxWidgets Application -# Last Change: 2016-11-27 Sun 15:03:01. +# Last Change: 2018-06-05 Tue 21:45:29. # by Takayuki Mutoh # @@ -20,7 +20,9 @@ # For Apple OSX else -WXCXXFLAGS = -I/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.1/lib/wx/include/osx_cocoa-unicode-3.1 -I/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.1/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__ +#WXCXXFLAGS = -I/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.1/lib/wx/include/osx_cocoa-unicode-3.1 -I/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.1/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__ +WXCXXFLAGS = -I/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.1/lib/wx/include/osx_cocoa-unicode-3.1 -I/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.1/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__ +#WXLIBS = -L/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.1/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lwx_osx_cocoau_xrc-3.1 -lwx_osx_cocoau_html-3.1 -lwx_osx_cocoau_qa-3.1 -lwx_osx_cocoau_adv-3.1 -lwx_osx_cocoau_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu_net-3.1 -lwx_baseu-3.1 WXLIBS = -L/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.1/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lwx_osx_cocoau_xrc-3.1 -lwx_osx_cocoau_html-3.1 -lwx_osx_cocoau_qa-3.1 -lwx_osx_cocoau_adv-3.1 -lwx_osx_cocoau_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu_net-3.1 -lwx_baseu-3.1 LIBS = $(WXLIBS) EXECUTABLE = $(PROGNAME).app/Contents/Pkginfo
--- a/main.cpp Sun Nov 27 20:15:37 2016 +0900 +++ b/main.cpp Tue Jun 05 22:09:21 2018 +0900 @@ -1,5 +1,5 @@ // Filename : main.cpp -// Last Change: 21-Jan-2014. +// Last Change: 2018-06-05 Tue 22:08:26. // #include "main.h" #include "myframe.h" @@ -29,7 +29,7 @@ long style = wxDEFAULT_FRAME_STYLE; style = style & ~( wxMAXIMIZE_BOX ); - MyFrame *mainframe = new MyFrame( NULL, wxID_ANY, wxT("IMCV - ImageConverter -"), wxDefaultPosition, wxSize( 450, 200 ), style ); + MyFrame *mainframe = new MyFrame( NULL, wxID_ANY, wxT("IMCV - ImageConverter -"), wxDefaultPosition, wxSize( 700, 200 ), style ); mainframe->Show(true); return true;
--- a/myframe.cpp Sun Nov 27 20:15:37 2016 +0900 +++ b/myframe.cpp Tue Jun 05 22:09:21 2018 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.cpp -// Last Change: 2016-11-27 Sun 20:08:02. +// Last Change: 2018-06-05 Tue 22:08:14. // #include "myframe.h" @@ -10,8 +10,7 @@ : wxFrame( parent, id, title, pos, size, style ) { this->SetIcon( wxIcon( wxT("sample") ) ); - //this->SetSizeHints( wxSize( 450, 200 ), wxSize( 450, 200 ) ); - this->SetSizeHints( wxSize( 550, 200 ), wxSize( 550, 200 ) ); + this->SetSizeHints( wxSize( 700, 200 ), wxSize( 700, 200 ) ); this->SetBackgroundColour( *wxBLACK ); wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); @@ -63,23 +62,30 @@ m_staticTextSize->SetBackgroundColour( *wxBLACK ); bSizerConfig->Add( m_staticTextSize, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_staticTextWidth = new wxStaticText( this, wxID_ANY, wxT("Width"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_staticTextWidth = new wxStaticText( this, wxID_ANY, wxT("Width"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextWidth->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); m_staticTextWidth->SetBackgroundColour( *wxBLACK ); bSizerConfig->Add( m_staticTextWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_textCtrlWidth = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 40, -1 ), wxTE_CENTRE ); - m_staticTextWidth->SetBackgroundColour( *wxBLACK ); + m_textCtrlWidth = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 50, -1 ), wxTE_RIGHT|wxTAB_TRAVERSAL ); bSizerConfig->Add( m_textCtrlWidth, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_staticTextHeight = new wxStaticText( this, wxID_ANY, wxT("Height"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_staticTextHeight = new wxStaticText( this, wxID_ANY, wxT("Height"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextHeight->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); m_staticTextHeight->SetBackgroundColour( *wxBLACK ); bSizerConfig->Add( m_staticTextHeight, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_textCtrlHeight = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 50, -1 ), wxTE_CENTRE ); + m_textCtrlHeight = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 50, -1 ), wxTE_RIGHT|wxTAB_TRAVERSAL ); bSizerConfig->Add( m_textCtrlHeight, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - + + m_staticTextPercent = new wxStaticText( this, wxID_ANY, wxT("Percent"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextPercent->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); + m_staticTextPercent->SetBackgroundColour( *wxBLACK ); + bSizerConfig->Add( m_staticTextPercent, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + m_textCtrlPercent = new wxTextCtrl( this, wxID_ANY, wxT("100"), wxDefaultPosition, wxSize( 40, -1 ), wxTE_RIGHT|wxTAB_TRAVERSAL ); + bSizerConfig->Add( m_textCtrlPercent, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerTop->Add( bSizerConfig, 1, wxEXPAND, 5 ); // Output @@ -147,7 +153,10 @@ buf = m_textCtrlHeight->GetValue(); buf.ToLong( &h, 10 ); - if ( choice_type == 0 && w == 0 && h == 0 ) { + buf = m_textCtrlPercent->GetValue(); + buf.ToLong( &s, 10 ); + + if ( choice_type == 0 && w == 0 && h == 0 && s == 100 ) { WarnMessage( wxT("no change !") ); return; } @@ -240,9 +249,14 @@ } wxImage image( file, in_type ); - if ( w == 0 || h == 0 ) { - w = (long)(image.GetWidth()); - h = (long)(image.GetHeight()); + if ( s == 100 ) { + if ( w == 0 || h == 0 ) { + w = (long)(image.GetWidth()); + h = (long)(image.GetHeight()); + } + } else { + w = (long)(image.GetWidth() * s / 100 ); + h = (long)(image.GetHeight() * s / 100 ); } wxImage output = image.Scale( (int)w, (int)h, wxIMAGE_QUALITY_HIGH ); wxString outfile = out_dir + wxFILE_SEP_PATH + name + wxT(".") + ext; @@ -330,9 +344,14 @@ if ( !tf.Exists() ) tf.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ); wxImage image( files[i], in_type ); - if ( w == 0 || h == 0 ) { - w = (long)(image.GetWidth()); - h = (long)(image.GetHeight()); + if ( s == 100 ) { + if ( w == 0 || h == 0 ) { + w = (long)(image.GetWidth()); + h = (long)(image.GetHeight()); + } + } else { + w = (long)(image.GetWidth() * s / 100 ); + h = (long)(image.GetHeight() * s / 100 ); } wxImage output = image.Scale( (int)w, (int)h, wxIMAGE_QUALITY_HIGH ); output.SaveFile( fullpath, out_type );
--- a/myframe.h Sun Nov 27 20:15:37 2016 +0900 +++ b/myframe.h Tue Jun 05 22:09:21 2018 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.h -// Last Change: 2016-11-27 Sun 14:19:57. +// Last Change: 2018-06-05 Tue 21:56:57. // #ifndef __MYFRAME_H__ #define __MYFRAME_H__ @@ -29,7 +29,7 @@ { DECLARE_EVENT_TABLE() private: - long w, h; + long w, h, s; int choice_type; wxString out_dir; @@ -44,6 +44,8 @@ wxTextCtrl* m_textCtrlWidth; wxStaticText* m_staticTextHeight; wxTextCtrl* m_textCtrlHeight; + wxStaticText* m_staticTextPercent; + wxTextCtrl* m_textCtrlPercent; wxStaticText* m_staticTextOutput; wxDirPickerCtrl* m_dirPicker; wxButton* m_buttonExec;