-
Notifications
You must be signed in to change notification settings - Fork 0
/
thumbnail.cpp
83 lines (69 loc) · 2.45 KB
/
thumbnail.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
/*
This file is part of Presenter,
copyright (c) 2013--2014 Jiří Župka.
Presenter is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Presenter is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Presenter. If not, see <http://www.gnu.org/licenses/>.
*/
#include "thumbnail.h"
#include <cmath>
#include "tools.h"
#include <QDebug>
#include <QImageReader>
#include <QFileInfo>
#include <omp.h>
#include <cassert>
Thumbnail::Thumbnail(QString path, unsigned int max_texture_size, QSize isize):
CacheImage(path, max_texture_size)
{
this->isize = isize;
}
Thumbnail::Thumbnail(const Thumbnail &image):
CacheImage(image)
{
this->isize = image.isize;
}
void Thumbnail::load(){
if (this->is_loaded()){
//qDebug() << "!!!!!!!!!!!!! Preloaded";
return;
}
QFileInfo media_info(path);
QString suffix = "*." + media_info.suffix();
suffix = suffix.toUpper();
if (this->supported_formats.indexOf(suffix) < 0){
this->b_loaded = true;
return;
}
QImageReader img_read(path);
QSize image_size = img_read.size();
float scale = 0.0;
float hw_isize = ((float)this->isize.height()) / this->isize.width();
float hw_image_size = ((float)image_size.height()) / image_size.width();
if (hw_image_size <= hw_isize){
scale = (float)this->isize.width() / image_size.width();
}else{
scale = (float)this->isize.height() / image_size.height();
}
//img_read.setQuality(100.0 / scale_y);
img_read.setScaledSize(QSize(((int(image_size.width() * scale)>>4)<<4),
((int(image_size.height() * scale)>>4)<<4)));
img_read.setQuality(93.0);
this->images.append(QVector <QImage>());
this->images[0].append(img_read.read());
//qDebug() << "Image Size image not loaded." << images[0][0].size();
this->sz = QSize(this->images[0][0].size());
this->img_hw = float(this->sz.height()) / this->sz.width();
this->angle = PI;
LoaderImage::load();
}
Thumbnail::~Thumbnail()
{
}