This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.cpp
157 lines (139 loc) · 4.61 KB
/
MainWindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include "MainWindow.h"
#include <QFile>
#include <QByteArray>
#include <QImage>
#include <QProcess>
#include <QDebug>
#include <QTimer>
#include <QImageReader>
#include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>
#include "EmbeddedImage.h"
#include "exif.h"
#include <stdio.h>
#include <exiv2/exiv2.hpp>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <QTextBrowser>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QColorSpace>
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
this->setWindowFlags(Qt::Window | Qt::X11BypassWindowManagerHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint);
//QTimer::singleShot(1000, this, SLOT(showFullScreen));
//resize(1024, 768);
displayLbl = new QLabel(this);
//this->setStyleSheet("background-color: black;");
/*
QFile f("/Users/dublin/Pictures/Ich/IMG_5098.CR2");
if (!f.open(QIODevice::ReadOnly))
{
// failed while open
}
QString imagePath;
EmbeddedImage *embImage = new EmbeddedImage("/Users/dublin/Pictures/Ich/IMG_5098.CR2");
if (embImage->extractEmbeddedImage())
{
imagePath = embImage->embeddedImagePath();
}
*/
// 5184 x 3456
#if 0
QByteArray arr = f.readAll();
unsigned char *ImgData = (unsigned char*)&arr.data()[0];
QImage theImage(ImgData, 5184, 3456, QImage::Format_RGB16);
displayLbl->setPixmap(QPixmap::fromImage(theImage));
#endif
QWidget *central = new QWidget(this);
QHBoxLayout *layout = new QHBoxLayout(this);
/*
QImageReader reader("/Users/dublin/Pictures/Ich/IMG_5098.CR2");
//reader.setScaledSize(QSize(1024, 768));
QImage raw = reader.read();
QSize size = reader.size();
*/
/*
QPixmap pix;
pix.load(imagePath);
pix = pix.scaled(1024, 768, Qt::KeepAspectRatio, Qt::SmoothTransformation);
displayLbl->setPixmap(pix);
*/
/*
displayLbl->setPixmap(QPixmap::fromImage(raw).scaled(1024, 768, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
layout->addWidget(displayLbl);
displayLbl->show();
*/
/*
QGraphicsScene *scene = new QGraphicsScene();
QGraphicsView *view = new QGraphicsView();
QImage small = raw.scaled(QSize(1024, 768), Qt::KeepAspectRatio, Qt::SmoothTransformation);
//if (raw.colorSpace().isValid()) {
raw.convertToColorSpace(QColorSpace::SRgb);
//}
scene->addPixmap(QPixmap::fromImage(small));
view->setScene(scene);
view->resize(1024, 768);
view->setMaximumSize(QSize(1024, 768));
view->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
layout->addWidget(view);
*/
imgPreview = new ImagePreview(this);
//imgPreview->setFixedSize(QSize(1280, 720));
imgPreview->scrollArea->setFixedSize(QSize(1280, 720));
imgPreview->loadImage("/Users/dublin/Pictures/Ich/IMG_5098.CR2");
layout->addWidget(imgPreview);
QTextBrowser *txtBrowser = new QTextBrowser(this);
#if 0
// Read the JPEG file into a buffer
FILE *fp = fopen("/Users/dublin/Pictures/Ich/IMG_5098.embedded.jpg", "rb");
if (!fp) {
printf("Can't open file.\n");
}
fseek(fp, 0, SEEK_END);
unsigned long fsize = ftell(fp);
rewind(fp);
unsigned char *buf = new unsigned char[fsize];
if (fread(buf, 1, fsize, fp) != fsize) {
printf("Can't read file.\n");
delete[] buf;
}
fclose(fp);
// Parse EXIF
easyexif::EXIFInfo result;
int code = result.parseFrom(buf, fsize);
delete[] buf;
if (code) {
printf("Error parsing EXIF: code %d\n", code);
}
#endif
Exiv2::Image::AutoPtr img = Exiv2::ImageFactory::open("/Users/dublin/Pictures/Ich/IMG_5098.CR2");
img->readMetadata();
Exiv2::ExifData &data = img->exifData();
std::stringstream buf;
Exiv2::ExifData::const_iterator end = data.end();
for (Exiv2::ExifData::const_iterator i = data.begin(); i != end; ++i) {
const char* tn = i->typeName();
buf << std::setw(44) << std::setfill(' ') << std::left
<< i->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << i->tag() << " "
<< std::setw(9) << std::setfill(' ') << std::left
<< (tn ? tn : "Unknown") << " "
<< std::dec << std::setw(3)
<< std::setfill(' ') << std::right
<< i->count() << " "
<< std::dec << i->value()
<< "\n";
}
txtBrowser->setText(QString::fromStdString(buf.str()));
layout->addWidget(txtBrowser);
central->setLayout(layout);
this->setCentralWidget(central);
}
MainWindow::~MainWindow()
{
}