Skip to content

Latest commit

 

History

History
57 lines (51 loc) · 1.54 KB

mms_attachment_qt.cpp

File metadata and controls

57 lines (51 loc) · 1.54 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
* Copyright (C) 2013-2014 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program 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.
*
*/
extern "C" {
#define MMS_LOG_MODULE_NAME mms_attachment_log
#include "mms_lib_log.h"
#include "mms_attachment_image.h"
}
#ifdef MMS_RESIZE_QT
Mar 5, 2014
Mar 5, 2014
23
#include <QtGui/QImage>
24
25
26
gboolean
mms_attachment_image_resize_qt(
May 12, 2014
May 12, 2014
27
28
MMSAttachmentImage* image,
const MMSSettingsSimData* s)
29
30
31
32
33
34
{
gboolean ok = FALSE;
QImage qimage;
if (qimage.load(image->attachment.original_file)) {
const int w = qimage.width();
const int h = qimage.height();
May 12, 2014
May 12, 2014
35
const int step = mms_attachment_image_next_resize_step(image, s, w, h);
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const char* fname = mms_attachment_image_prepare_filename(image);
const int w1 = w/(step+1);
QImage scaled = qimage.scaledToWidth(w1, Qt::SmoothTransformation);
if (scaled.save(fname)) {
MMS_DEBUG("Scaling %s (%dx%d -> %dx%d) with Qt", fname, w, h,
scaled.width(), scaled.height());
image->resize_step = step;
ok = TRUE;
}
}
return ok;
}
#endif /* MMS_RESIZE_QT */
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/