From fd84a9f73dd5fffebdf122a0ecd154281b701d52 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 15 Apr 2010 12:22:19 +0000 Subject: * move QImage-related code out of QXmppUtils * make it possible to disable QtGui-dependent code --- source/QXmppUtils.cpp | 56 +++++++-------------------------------------------- 1 file changed, 7 insertions(+), 49 deletions(-) (limited to 'source/QXmppUtils.cpp') diff --git a/source/QXmppUtils.cpp b/source/QXmppUtils.cpp index f59462a1..bf58706b 100644 --- a/source/QXmppUtils.cpp +++ b/source/QXmppUtils.cpp @@ -22,17 +22,16 @@ */ -#include "QXmppUtils.h" -#include "QXmppLogger.h" +#include +#include +#include #include +#include #include #include -#include -#include -#include -#include -#include -#include + +#include "QXmppUtils.h" +#include "QXmppLogger.h" QDateTime datetimeFromString(const QString &str) { @@ -137,45 +136,4 @@ QString unescapeString(const QString& str) return strOut; } -QString getImageType(const QByteArray& image) -{ - QBuffer buffer; - buffer.setData(image); - buffer.open(QIODevice::ReadOnly); - QString format = QImageReader::imageFormat(&buffer); - - if(format.toUpper() == "PNG") - return "image/png"; - else if(format.toUpper() == "MNG") - return "video/x-mng"; - else if(format.toUpper() == "GIF") - return "image/gif"; - else if(format.toUpper() == "BMP") - return "image/bmp"; - else if(format.toUpper() == "XPM") - return "image/x-xpm"; - else if(format.toUpper() == "SVG") - return "image/svg+xml"; - else if(format.toUpper() == "JPEG") - return "image/jpeg"; - - return "image/unknown"; -} -QString getImageHash(const QByteArray& image) -{ - if(image.isEmpty()) - return ""; - else - return QString(QCryptographicHash::hash(image, - QCryptographicHash::Sha1).toHex()); -} - -QImage getImageFromByteArray(const QByteArray& image) -{ - QBuffer buffer; - buffer.setData(image); - buffer.open(QIODevice::ReadOnly); - QImageReader imageReader(&buffer); - return imageReader.read(); -} -- cgit v1.2.3