From b110d11d15d2e67b3cb00ea1d84a08c60d375c3d Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Wed, 1 Sep 2010 08:29:31 +0000 Subject: add code for using getImageType without QtGui --- src/QXmppVCard.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'src/QXmppVCard.cpp') diff --git a/src/QXmppVCard.cpp b/src/QXmppVCard.cpp index 9b4b93b2..ee336805 100644 --- a/src/QXmppVCard.cpp +++ b/src/QXmppVCard.cpp @@ -34,32 +34,22 @@ #include "QXmppUtils.h" #include "QXmppConstants.h" -static QString getImageType(const QByteArray& image) +QString getImageType(const QByteArray &contents) { -#ifndef QXMPP_NO_GUI - QBuffer buffer; - buffer.setData(image); - buffer.open(QIODevice::ReadOnly); - QString format = QImageReader::imageFormat(&buffer); - - if(format.toUpper() == "PNG") + if (contents.startsWith("\x89PNG\x0d\x0a\x1a\x0a")) return "image/png"; - else if(format.toUpper() == "MNG") + else if (contents.startsWith("\x8aMNG")) return "video/x-mng"; - else if(format.toUpper() == "GIF") + else if (contents.startsWith("GIF8")) return "image/gif"; - else if(format.toUpper() == "BMP") + else if (contents.startsWith("BM")) return "image/bmp"; - else if(format.toUpper() == "XPM") + else if (contents.contains("/* XPM */")) return "image/x-xpm"; - else if(format.toUpper() == "SVG") - return "image/svg+xml"; - else if(format.toUpper() == "JPEG") + else if (contents.contains("