summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qimagereader.cpp75
-rw-r--r--src/gui/image/qimagereader.h1
-rw-r--r--src/gui/image/qimagewriter.cpp85
-rw-r--r--src/gui/image/qimagewriter.h1
-rw-r--r--src/gui/painting/qgrayraster.c10
5 files changed, 132 insertions, 40 deletions
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index 6836035e59..dfdc3fdc2d 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -186,31 +186,32 @@ struct _qt_BuiltInFormatStruct
{
_qt_BuiltInFormatType type;
const char *extension;
+ const char *mimeType;
};
static const _qt_BuiltInFormatStruct _qt_BuiltInFormats[] = {
#ifndef QT_NO_IMAGEFORMAT_PNG
- {_qt_PngFormat, "png"},
+ {_qt_PngFormat, "png", "image/png"},
#endif
#ifndef QT_NO_IMAGEFORMAT_JPEG
- {_qt_JpgFormat, "jpg"},
+ {_qt_JpgFormat, "jpg", "image/jpeg"},
#endif
#ifdef QT_BUILTIN_GIF_READER
- {_qt_GifFormat, "gif"},
+ {_qt_GifFormat, "gif", "image/gif"},
#endif
- {_qt_BmpFormat, "bmp"},
+ {_qt_BmpFormat, "bmp", "image/bmp"},
#ifndef QT_NO_IMAGEFORMAT_PPM
- {_qt_PpmFormat, "ppm"},
- {_qt_PgmFormat, "pgm"},
- {_qt_PbmFormat, "pbm"},
+ {_qt_PpmFormat, "ppm", "image/x-portable-pixmap"},
+ {_qt_PgmFormat, "pgm", "image/x-portable-graymap"},
+ {_qt_PbmFormat, "pbm", "image/x-portable-bitmap"},
#endif
#ifndef QT_NO_IMAGEFORMAT_XBM
- {_qt_XbmFormat, "xbm"},
+ {_qt_XbmFormat, "xbm", "image/x-xbitmap"},
#endif
#ifndef QT_NO_IMAGEFORMAT_XPM
- {_qt_XpmFormat, "xpm"},
+ {_qt_XpmFormat, "xpm", "image/x-xpixmap"},
#endif
- {_qt_NoFormat, ""}
+ {_qt_NoFormat, "", ""}
};
static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
@@ -1434,6 +1435,10 @@ QByteArray QImageReader::imageFormat(QIODevice *device)
void supportedImageHandlerFormats(QFactoryLoader *loader,
QImageIOPlugin::Capability cap,
QSet<QByteArray> *result);
+
+void supportedImageHandlerMimeTypes(QFactoryLoader *loader,
+ QImageIOPlugin::Capability cap,
+ QSet<QByteArray> *result);
#endif
/*!
@@ -1442,18 +1447,17 @@ void supportedImageHandlerFormats(QFactoryLoader *loader,
By default, Qt can read the following formats:
\table
- \header \li Format \li Description
- \row \li BMP \li Windows Bitmap
- \row \li GIF \li Graphic Interchange Format (optional)
- \row \li JPG \li Joint Photographic Experts Group
- \row \li JPEG \li Joint Photographic Experts Group
- \row \li PNG \li Portable Network Graphics
- \row \li PBM \li Portable Bitmap
- \row \li PGM \li Portable Graymap
- \row \li PPM \li Portable Pixmap
- \row \li XBM \li X11 Bitmap
- \row \li XPM \li X11 Pixmap
- \row \li SVG \li Scalable Vector Graphics
+ \header \li Format \li MIME type \li Description
+ \row \li BMP \li image/bmp \li Windows Bitmap
+ \row \li GIF \li image/gif \li Graphic Interchange Format (optional)
+ \row \li JPG \li image/jpeg \li Joint Photographic Experts Group
+ \row \li PNG \li image/png \li Portable Network Graphics
+ \row \li PBM \li image/x-portable-bitmap \li Portable Bitmap
+ \row \li PGM \li image/x-portable-graymap \li Portable Graymap
+ \row \li PPM \li image/x-portable-pixmap \li Portable Pixmap
+ \row \li XBM \li image/x-xbitmap \li X11 Bitmap
+ \row \li XPM \li image/x-xpixmap \li X11 Pixmap
+ \row \li SVG \li image/svg+xml \li Scalable Vector Graphics
\endtable
Reading and writing SVG files is supported through Qt's
@@ -1484,4 +1488,31 @@ QList<QByteArray> QImageReader::supportedImageFormats()
return sortedFormats;
}
+/*!
+ Returns the list of MIME types supported by QImageReader.
+
+ Note that the QApplication instance must be created before this function is
+ called.
+
+ \sa supportedImageFormats(), QImageWriter::supportedMimeTypes()
+*/
+
+QList<QByteArray> QImageReader::supportedMimeTypes()
+{
+ QSet<QByteArray> mimeTypes;
+ for (int i = 0; i < _qt_NumFormats; ++i)
+ mimeTypes << _qt_BuiltInFormats[i].mimeType;
+
+#ifndef QT_NO_LIBRARY
+ supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanRead, &mimeTypes);
+#endif // QT_NO_LIBRARY
+
+ QList<QByteArray> sortedMimeTypes;
+ for (QSet<QByteArray>::ConstIterator it = mimeTypes.constBegin(); it != mimeTypes.constEnd(); ++it)
+ sortedMimeTypes << *it;
+
+ qSort(sortedMimeTypes);
+ return sortedMimeTypes;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qimagereader.h b/src/gui/image/qimagereader.h
index 11c925b142..a989ded0db 100644
--- a/src/gui/image/qimagereader.h
+++ b/src/gui/image/qimagereader.h
@@ -133,6 +133,7 @@ public:
static QByteArray imageFormat(const QString &fileName);
static QByteArray imageFormat(QIODevice *device);
static QList<QByteArray> supportedImageFormats();
+ static QList<QByteArray> supportedMimeTypes();
private:
Q_DISABLE_COPY(QImageReader)
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
index 3270a5ca01..67b21e372e 100644
--- a/src/gui/image/qimagewriter.cpp
+++ b/src/gui/image/qimagewriter.cpp
@@ -100,6 +100,7 @@
#include <qfile.h>
#include <qfileinfo.h>
#include <qimageiohandler.h>
+#include <qjsonarray.h>
#include <qset.h>
#include <qvariant.h>
@@ -677,6 +678,26 @@ void supportedImageHandlerFormats(QFactoryLoader *loader,
result->insert(key);
}
}
+
+void supportedImageHandlerMimeTypes(QFactoryLoader *loader,
+ QImageIOPlugin::Capability cap,
+ QSet<QByteArray> *result)
+{
+ QList<QJsonObject> metaDataList = loader->metaData();
+
+ const int pluginCount = metaDataList.size();
+ for (int i = 0; i < pluginCount; ++i) {
+ const QJsonObject metaData = metaDataList.at(i).value(QStringLiteral("MetaData")).toObject();
+ const QJsonArray keys = metaData.value(QStringLiteral("Keys")).toArray();
+ const QJsonArray mimeTypes = metaData.value(QStringLiteral("MimeTypes")).toArray();
+ QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(loader->instance(i));
+ const int keyCount = keys.size();
+ for (int k = 0; k < keyCount; ++k) {
+ if (plugin && (plugin->capabilities(0, keys.at(k).toString().toLatin1()) & cap) != 0)
+ result->insert(mimeTypes.at(k).toString().toLatin1());
+ }
+ }
+}
#endif // QT_NO_IMAGEFORMATPLUGIN
/*!
@@ -685,16 +706,15 @@ void supportedImageHandlerFormats(QFactoryLoader *loader,
By default, Qt can write the following formats:
\table
- \header \li Format \li Description
- \row \li BMP \li Windows Bitmap
- \row \li JPG \li Joint Photographic Experts Group
- \row \li JPEG \li Joint Photographic Experts Group
- \row \li PNG \li Portable Network Graphics
- \row \li PBM \li Portable Bitmap
- \row \li PGM \li Portable Graymap
- \row \li PPM \li Portable Pixmap
- \row \li XBM \li X11 Bitmap
- \row \li XPM \li X11 Pixmap
+ \header \li Format \li MIME type \li Description
+ \row \li BMP \li image/bmp \li Windows Bitmap
+ \row \li JPG \li image/jpeg \li Joint Photographic Experts Group
+ \row \li PNG \li image/png \li Portable Network Graphics
+ \row \li PBM \li image/x-portable-bitmap \li Portable Bitmap
+ \row \li PGM \li image/x-portable-graymap \li Portable Graymap
+ \row \li PPM \li image/x-portable-pixmap \li Portable Pixmap
+ \row \li XBM \li image/x-xbitmap \li X11 Bitmap
+ \row \li XPM \li image/x-xpixmap \li X11 Pixmap
\endtable
Reading and writing SVG files is supported through Qt's
@@ -725,9 +745,6 @@ QList<QByteArray> QImageWriter::supportedImageFormats()
#ifndef QT_NO_IMAGEFORMAT_JPEG
formats << "jpg" << "jpeg";
#endif
-#ifdef QT_BUILTIN_GIF_READER
- formats << "gif";
-#endif
#ifndef QT_NO_IMAGEFORMATPLUGIN
supportedImageHandlerFormats(loader(), QImageIOPlugin::CanWrite, &formats);
@@ -741,4 +758,46 @@ QList<QByteArray> QImageWriter::supportedImageFormats()
return sortedFormats;
}
+/*!
+ Returns the list of MIME types supported by QImageWriter.
+
+ Note that the QApplication instance must be created before this function is
+ called.
+
+ \sa supportedImageFormats(), QImageReader::supportedMimeTypes()
+*/
+QList<QByteArray> QImageWriter::supportedMimeTypes()
+{
+ QSet<QByteArray> mimeTypes;
+ mimeTypes << "image/bmp";
+#ifndef QT_NO_IMAGEFORMAT_PPM
+ mimeTypes << "image/x-portable-bitmap";
+ mimeTypes << "image/x-portable-graymap";
+ mimeTypes << "image/x-portable-pixmap";
+#endif
+#ifndef QT_NO_IMAGEFORMAT_XBM
+ mimeTypes << "image/x-xbitmap";
+#endif
+#ifndef QT_NO_IMAGEFORMAT_XPM
+ mimeTypes << "image/x-xpixmap";
+#endif
+#ifndef QT_NO_IMAGEFORMAT_PNG
+ mimeTypes << "image/png";
+#endif
+#ifndef QT_NO_IMAGEFORMAT_JPEG
+ mimeTypes << "image/jpeg";
+#endif
+
+#ifndef QT_NO_LIBRARY
+ supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanWrite, &mimeTypes);
+#endif // QT_NO_LIBRARY
+
+ QList<QByteArray> sortedMimeTypes;
+ for (QSet<QByteArray>::ConstIterator it = mimeTypes.constBegin(); it != mimeTypes.constEnd(); ++it)
+ sortedMimeTypes << *it;
+
+ qSort(sortedMimeTypes);
+ return sortedMimeTypes;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qimagewriter.h b/src/gui/image/qimagewriter.h
index 7d05cd5236..7a93f00d8e 100644
--- a/src/gui/image/qimagewriter.h
+++ b/src/gui/image/qimagewriter.h
@@ -102,6 +102,7 @@ public:
bool supportsOption(QImageIOHandler::ImageOption option) const;
static QList<QByteArray> supportedImageFormats();
+ static QList<QByteArray> supportedMimeTypes();
private:
Q_DISABLE_COPY(QImageWriter)
diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c
index 8be462517c..7dfb743ae2 100644
--- a/src/gui/painting/qgrayraster.c
+++ b/src/gui/painting/qgrayraster.c
@@ -1736,9 +1736,9 @@
if ( raster->worker )
raster->worker->skip_spans = params->skip_spans;
- // If raster object and raster buffer are allocated, but
- // raster size isn't of the minimum size, indicate out of
- // memory.
+ /* If raster object and raster buffer are allocated, but */
+ /* raster size isn't of the minimum size, indicate out of */
+ /* memory. */
if (raster->buffer_allocated_size < MINIMUM_POOL_SIZE )
return ErrRaster_OutOfMemory;
@@ -1866,8 +1866,8 @@
( sizeof ( TCell ) * 8 ) );
}
else if ( pool_base)
- { // Case when there is a raster pool allocated, but it
- // doesn't have the minimum size (and so memory will be reallocated)
+ { /* Case when there is a raster pool allocated, but it */
+ /* doesn't have the minimum size (and so memory will be reallocated) */
rast->buffer = pool_base;
rast->worker = NULL;
rast->buffer_size = pool_size;