-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.cpp
53 lines (41 loc) · 985 Bytes
/
image.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
// image.cpp
#include "image.h"
#include <QBuffer>
#include <QPixmap>
Image::Image(const QImage &image, const QByteArray &hash, double similarityPercentage, qlonglong dateInSeconds)
: QImage(image), hash(hash), similarityPercentage(similarityPercentage), dateInSeconds(dateInSeconds)
{
}
QByteArray Image::getHash() const
{
return hash;
}
double Image::getSimilarityPercentage() const
{
return similarityPercentage;
}
qlonglong Image::getDate() const
{
return dateInSeconds;
}
void Image::setHash(QByteArray h)
{
hash = h;
}
void Image::setSimilarityPercentage(double similarity)
{
similarityPercentage = similarity;
}
void Image::setDate(qlonglong date)
{
dateInSeconds = date;
}
QByteArray Image::asByteArray() const
{
QPixmap inPixmap = QPixmap::fromImage(*this);
QByteArray inByteArray;
QBuffer inBuffer( &inByteArray );
inBuffer.open( QIODevice::WriteOnly );
inPixmap.save( &inBuffer, "PNG" );
return inByteArray;
}