File tree Expand file tree Collapse file tree 2 files changed +64
-0
lines changed
Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ #include < QApplication>
3+ #include < QDebug>
4+ #include < QImage>
5+ #include < QLabel>
6+
7+ int main (int argc, char *argv[])
8+ {
9+ QApplication a (argc, argv);
10+
11+ for (int i = 1 ; i < argc; i++) {
12+ const QString imgPath (argv[i]);
13+ QImage image (imgPath);
14+ if (!image.isNull ()) {
15+ qDebug () << " image size:" << image.size ();
16+ QLabel* label = new QLabel ();
17+ int w = 0 ;
18+ int h = 0 ;
19+ if (image.width () > image.height ()) {
20+ w = 1400 ;
21+ h = (1.0 * image.height ()) / (1.0 * image.width () * 1400 );
22+ } else {
23+ h = 1400 ;
24+ w = (1.0 * 1400 * image.height ()) /(1.0 * image.width ());
25+ }
26+ qDebug () << w << h;
27+ const QPixmap pixmap = QPixmap::fromImage (image);
28+ label->setPixmap (pixmap);
29+ label->show ();
30+ label->resize (image.size ());
31+ } else {
32+ qCritical () << " Invalid image:" << imgPath;
33+ }
34+ }
35+
36+ return a.exec ();
37+ }
Original file line number Diff line number Diff line change 1+ # -------------------------------------------------
2+ #
3+ # Project created by QtCreator 2018-06-04T17:24:34
4+ #
5+ # -------------------------------------------------
6+
7+ QT += core gui
8+
9+ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10+
11+ TARGET = qtheif
12+ TEMPLATE = app
13+
14+ # The following define makes your compiler emit warnings if you use
15+ # any feature of Qt which as been marked as deprecated (the exact warnings
16+ # depend on your compiler). Please consult the documentation of the
17+ # deprecated API in order to know how to port your code away from it.
18+ DEFINES += QT_DEPRECATED_WARNINGS
19+
20+ # You can also make your code fail to compile if you use deprecated APIs.
21+ # In order to do so, uncomment the following line.
22+ # You can also select to disable deprecated APIs only up to a certain version of Qt.
23+ # DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
24+
25+
26+ SOURCES += \
27+ main.cpp
You can’t perform that action at this time.
0 commit comments