Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[mms-lib] Added support for Qt-based resizing
That allows to eliminate dependency on ImageMagick. Qt/ImageMagick switch is located in mms-lib/Config.mak
- Loading branch information
Showing
13 changed files
with
191 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- Mode: makefile-gmake -*- | ||
|
||
MMS_RESIZE = ImageMagick | ||
#MMS_RESIZE = Qt | ||
|
||
# | ||
# ImageMagick support | ||
# | ||
|
||
ifeq ($(MMS_RESIZE),ImageMagick) | ||
RESIZE_DEFINES = -DMMS_RESIZE_IMAGEMAGICK | ||
RESIZE_PKG = ImageMagick | ||
else | ||
ifeq ($(MMS_RESIZE),Qt) | ||
RESIZE_LIBS = -lstdc++ | ||
RESIZE_DEFINES = -DMMS_RESIZE_QT | ||
ifeq ($(shell qmake --version | grep "Using Qt version 5"),) | ||
RESIZE_PKG = QtGui | ||
else | ||
RESIZE_PKG = Qt5Gui | ||
endif | ||
endif | ||
endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#CONFIG += ResizeImageMagick | ||
CONFIG += ResizeQt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 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 | ||
|
||
#include <QtGui/QtGui> | ||
|
||
gboolean | ||
mms_attachment_image_resize_qt( | ||
MMSAttachmentImage* image) | ||
{ | ||
gboolean ok = FALSE; | ||
QImage qimage; | ||
if (qimage.load(image->attachment.original_file)) { | ||
const int w = qimage.width(); | ||
const int h = qimage.height(); | ||
const int step = mms_attachment_image_next_resize_step(image, w, h); | ||
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: | ||
*/ |
Oops, something went wrong.