Mercurial > mercurial > hgweb_imcv.cgi
comparison myframe.cpp @ 4:3fadcf124bb4
add Percent.
author | pyon@macmini |
---|---|
date | Tue, 05 Jun 2018 22:09:21 +0900 |
parents | cc1f1fa544a4 |
children | cb33c4b9ea23 |
comparison
equal
deleted
inserted
replaced
3:cc1f1fa544a4 | 4:3fadcf124bb4 |
---|---|
1 // Filename : myframe.cpp | 1 // Filename : myframe.cpp |
2 // Last Change: 2016-11-27 Sun 20:08:02. | 2 // Last Change: 2018-06-05 Tue 22:08:14. |
3 // | 3 // |
4 | 4 |
5 #include "myframe.h" | 5 #include "myframe.h" |
6 #include "dndfile.h" | 6 #include "dndfile.h" |
7 #include "sample.xpm" | 7 #include "sample.xpm" |
8 | 8 |
9 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | 9 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) |
10 : wxFrame( parent, id, title, pos, size, style ) | 10 : wxFrame( parent, id, title, pos, size, style ) |
11 { | 11 { |
12 this->SetIcon( wxIcon( wxT("sample") ) ); | 12 this->SetIcon( wxIcon( wxT("sample") ) ); |
13 //this->SetSizeHints( wxSize( 450, 200 ), wxSize( 450, 200 ) ); | 13 this->SetSizeHints( wxSize( 700, 200 ), wxSize( 700, 200 ) ); |
14 this->SetSizeHints( wxSize( 550, 200 ), wxSize( 550, 200 ) ); | |
15 this->SetBackgroundColour( *wxBLACK ); | 14 this->SetBackgroundColour( *wxBLACK ); |
16 | 15 |
17 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); | 16 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); |
18 | 17 |
19 // Source | 18 // Source |
61 m_staticTextSize = new wxStaticText( this, wxID_ANY, wxT("Size"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); | 60 m_staticTextSize = new wxStaticText( this, wxID_ANY, wxT("Size"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); |
62 m_staticTextSize->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); | 61 m_staticTextSize->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); |
63 m_staticTextSize->SetBackgroundColour( *wxBLACK ); | 62 m_staticTextSize->SetBackgroundColour( *wxBLACK ); |
64 bSizerConfig->Add( m_staticTextSize, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 63 bSizerConfig->Add( m_staticTextSize, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
65 | 64 |
66 m_staticTextWidth = new wxStaticText( this, wxID_ANY, wxT("Width"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); | 65 m_staticTextWidth = new wxStaticText( this, wxID_ANY, wxT("Width"), wxDefaultPosition, wxDefaultSize, 0 ); |
67 m_staticTextWidth->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); | 66 m_staticTextWidth->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); |
68 m_staticTextWidth->SetBackgroundColour( *wxBLACK ); | 67 m_staticTextWidth->SetBackgroundColour( *wxBLACK ); |
69 bSizerConfig->Add( m_staticTextWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); | 68 bSizerConfig->Add( m_staticTextWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); |
70 | 69 |
71 m_textCtrlWidth = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 40, -1 ), wxTE_CENTRE ); | 70 m_textCtrlWidth = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 50, -1 ), wxTE_RIGHT|wxTAB_TRAVERSAL ); |
72 m_staticTextWidth->SetBackgroundColour( *wxBLACK ); | |
73 bSizerConfig->Add( m_textCtrlWidth, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 71 bSizerConfig->Add( m_textCtrlWidth, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
74 | 72 |
75 m_staticTextHeight = new wxStaticText( this, wxID_ANY, wxT("Height"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); | 73 m_staticTextHeight = new wxStaticText( this, wxID_ANY, wxT("Height"), wxDefaultPosition, wxDefaultSize, 0 ); |
76 m_staticTextHeight->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); | 74 m_staticTextHeight->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); |
77 m_staticTextHeight->SetBackgroundColour( *wxBLACK ); | 75 m_staticTextHeight->SetBackgroundColour( *wxBLACK ); |
78 bSizerConfig->Add( m_staticTextHeight, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); | 76 bSizerConfig->Add( m_staticTextHeight, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); |
79 | 77 |
80 m_textCtrlHeight = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 50, -1 ), wxTE_CENTRE ); | 78 m_textCtrlHeight = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 50, -1 ), wxTE_RIGHT|wxTAB_TRAVERSAL ); |
81 bSizerConfig->Add( m_textCtrlHeight, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 79 bSizerConfig->Add( m_textCtrlHeight, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
82 | 80 |
81 m_staticTextPercent = new wxStaticText( this, wxID_ANY, wxT("Percent"), wxDefaultPosition, wxDefaultSize, 0 ); | |
82 m_staticTextPercent->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); | |
83 m_staticTextPercent->SetBackgroundColour( *wxBLACK ); | |
84 bSizerConfig->Add( m_staticTextPercent, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); | |
85 | |
86 m_textCtrlPercent = new wxTextCtrl( this, wxID_ANY, wxT("100"), wxDefaultPosition, wxSize( 40, -1 ), wxTE_RIGHT|wxTAB_TRAVERSAL ); | |
87 bSizerConfig->Add( m_textCtrlPercent, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
88 | |
83 bSizerTop->Add( bSizerConfig, 1, wxEXPAND, 5 ); | 89 bSizerTop->Add( bSizerConfig, 1, wxEXPAND, 5 ); |
84 | 90 |
85 // Output | 91 // Output |
86 wxBoxSizer* bSizerOutput = new wxBoxSizer( wxHORIZONTAL ); | 92 wxBoxSizer* bSizerOutput = new wxBoxSizer( wxHORIZONTAL ); |
87 | 93 |
145 buf = m_textCtrlWidth->GetValue(); | 151 buf = m_textCtrlWidth->GetValue(); |
146 buf.ToLong( &w, 10 ); | 152 buf.ToLong( &w, 10 ); |
147 buf = m_textCtrlHeight->GetValue(); | 153 buf = m_textCtrlHeight->GetValue(); |
148 buf.ToLong( &h, 10 ); | 154 buf.ToLong( &h, 10 ); |
149 | 155 |
150 if ( choice_type == 0 && w == 0 && h == 0 ) { | 156 buf = m_textCtrlPercent->GetValue(); |
157 buf.ToLong( &s, 10 ); | |
158 | |
159 if ( choice_type == 0 && w == 0 && h == 0 && s == 100 ) { | |
151 WarnMessage( wxT("no change !") ); | 160 WarnMessage( wxT("no change !") ); |
152 return; | 161 return; |
153 } | 162 } |
154 | 163 |
155 buf = m_dirPicker->GetPath(); | 164 buf = m_dirPicker->GetPath(); |
238 else if ( choice_type == 8 ) { | 247 else if ( choice_type == 8 ) { |
239 // SVG | 248 // SVG |
240 } | 249 } |
241 | 250 |
242 wxImage image( file, in_type ); | 251 wxImage image( file, in_type ); |
243 if ( w == 0 || h == 0 ) { | 252 if ( s == 100 ) { |
244 w = (long)(image.GetWidth()); | 253 if ( w == 0 || h == 0 ) { |
245 h = (long)(image.GetHeight()); | 254 w = (long)(image.GetWidth()); |
255 h = (long)(image.GetHeight()); | |
256 } | |
257 } else { | |
258 w = (long)(image.GetWidth() * s / 100 ); | |
259 h = (long)(image.GetHeight() * s / 100 ); | |
246 } | 260 } |
247 wxImage output = image.Scale( (int)w, (int)h, wxIMAGE_QUALITY_HIGH ); | 261 wxImage output = image.Scale( (int)w, (int)h, wxIMAGE_QUALITY_HIGH ); |
248 wxString outfile = out_dir + wxFILE_SEP_PATH + name + wxT(".") + ext; | 262 wxString outfile = out_dir + wxFILE_SEP_PATH + name + wxT(".") + ext; |
249 | 263 |
250 if ( file.IsSameAs( outfile ) ) { | 264 if ( file.IsSameAs( outfile ) ) { |
328 | 342 |
329 wxFileName tf( fullpath ); | 343 wxFileName tf( fullpath ); |
330 if ( !tf.Exists() ) tf.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ); | 344 if ( !tf.Exists() ) tf.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ); |
331 | 345 |
332 wxImage image( files[i], in_type ); | 346 wxImage image( files[i], in_type ); |
333 if ( w == 0 || h == 0 ) { | 347 if ( s == 100 ) { |
334 w = (long)(image.GetWidth()); | 348 if ( w == 0 || h == 0 ) { |
335 h = (long)(image.GetHeight()); | 349 w = (long)(image.GetWidth()); |
350 h = (long)(image.GetHeight()); | |
351 } | |
352 } else { | |
353 w = (long)(image.GetWidth() * s / 100 ); | |
354 h = (long)(image.GetHeight() * s / 100 ); | |
336 } | 355 } |
337 wxImage output = image.Scale( (int)w, (int)h, wxIMAGE_QUALITY_HIGH ); | 356 wxImage output = image.Scale( (int)w, (int)h, wxIMAGE_QUALITY_HIGH ); |
338 output.SaveFile( fullpath, out_type ); | 357 output.SaveFile( fullpath, out_type ); |
339 } | 358 } |
340 | 359 |