equal
deleted
inserted
replaced
|
1 #include <wx/wx.h> |
|
2 #include <wx/log.h> |
|
3 #include <wx/image.h> |
|
4 #include <wx/string.h> |
|
5 #include <wx/init.h> |
|
6 |
|
7 #include "MainWindow.hpp" |
|
8 |
|
9 class MyApp : public wxApp |
|
10 { |
|
11 public: |
|
12 virtual bool OnInit(); |
|
13 }; |
|
14 |
|
15 IMPLEMENT_APP(MyApp) |
|
16 |
|
17 bool MyApp::OnInit() |
|
18 { |
|
19 if (argc < 2) |
|
20 return false; |
|
21 |
|
22 ::wxInitAllImageHandlers(); |
|
23 |
|
24 wxString filename(argv[1]); |
|
25 |
|
26 wxLogVerbose(_T("Opening file %s."), filename.c_str()); |
|
27 wxImage img(filename); |
|
28 if (!img.IsOk()) |
|
29 return false; |
|
30 |
|
31 CropArea area; |
|
32 if (argc < 6) |
|
33 { |
|
34 area.x = 0; |
|
35 area.y = 0; |
|
36 area.width = 0; |
|
37 area.height = 0; |
|
38 } |
|
39 else |
|
40 { |
|
41 wxString(argv[2]).ToLong(&area.x); |
|
42 wxString(argv[3]).ToLong(&area.y); |
|
43 wxString(argv[4]).ToLong(&area.width); |
|
44 wxString(argv[5]).ToLong(&area.height); |
|
45 } |
|
46 |
|
47 img.Rescale(img.GetWidth()/3, img.GetHeight()/3); |
|
48 |
|
49 wxSize size(img.GetWidth(), img.GetHeight()); |
|
50 MainWindow *mw = new MainWindow(img, area, size); |
|
51 mw->Show(); |
|
52 |
|
53 return true; |
|
54 } |