Project

General

Profile

Support #2624 ยป main.cpp

Anonymous, 01/31/2014 10:13 AM

 
1
#include <Wt/WApplication>
2
#include <Wt/WContainerWidget>
3
#include <Wt/WFileUpload>
4
#include <Wt/WHBoxLayout>
5
#include <Wt/WBorderLayout>
6
#include <Wt/WText>
7
#include <Wt/WImage>
8
#include <Wt/WFileResource>
9
#include <QImage>
10
#include <qstring.h>
11

    
12

    
13
using namespace Wt;
14

    
15
#include <iostream>
16

    
17
using namespace std;
18

    
19
class HelloApplication : public WApplication 
20
{
21
public:
22
HelloApplication(const WEnvironment& env);
23
WFileUpload *upload ;
24
void FileUploaded();
25
};
26

    
27
HelloApplication::HelloApplication(const WEnvironment& env)
28
: WApplication(env)
29
 {
30
setTitle("Hello");
31

    
32
 upload = new WFileUpload(root());
33
  upload->setFileTextSize(40);
34
  upload->changed().connect(upload, &WFileUpload::upload);
35
  upload->uploaded().connect(this, &HelloApplication::FileUploaded);
36
}
37

    
38
void HelloApplication::FileUploaded()
39
 {
40
std::string spool = upload->spoolFileName();
41
Wt::WFileResource *imageFile = new Wt::WFileResource("image/png", spool);
42
imageFile->suggestFileName("down.png");
43
Wt::WImage *image = new Wt::WImage(imageFile, "PNG version");
44
root()->addWidget(image);
45

    
46
QImage img;
47
   img.load(QString::fromStdString(spool));
48
   int n=img.width();
49

    
50
	WText * text=new WText("",root());
51
	string s = boost::lexical_cast<string>(n);
52
	text->setText(s);
53
	 bool check=img.save("rk.jpg");
54
	 if(check)
55
		 text->setText("Save");
56
	 else
57
		 text->setText("Not Saved");
58

    
59
	 img.save("D:\\Test\\love.jpg");
60

    
61
}
62

    
63

    
64
WApplication *createApplication(const WEnvironment& env) {
65
return new HelloApplication(env);
66
}
67

    
68
int main(int argc, char **argv) 
69
{
70
//setenv("WT_TMP_DIR", "/home/ubuntu/webapp/source/tmp", 1);
71
return WRun(argc, argv, &createApplication);
72
}
73

    
74

    
75

    
76

    
    (1-1/1)