summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/image.pri5
-rw-r--r--src/gui/image/qbmphandler.cpp8
-rw-r--r--src/gui/image/qimage.cpp185
-rw-r--r--src/gui/image/qimage.h161
-rw-r--r--src/gui/image/qimage_compat.cpp66
-rw-r--r--src/gui/image/qimage_p.h4
-rw-r--r--src/gui/image/qpicture.cpp832
-rw-r--r--src/gui/image/qpicture.h78
-rw-r--r--src/gui/image/qpictureformatplugin.cpp135
-rw-r--r--src/gui/image/qpictureformatplugin.h76
-rw-r--r--src/gui/image/qpixmap_win.cpp2
-rw-r--r--src/gui/image/qplatformpixmap.cpp4
-rw-r--r--src/gui/image/qplatformpixmap.h2
-rw-r--r--src/gui/image/qpnghandler.cpp4
-rw-r--r--src/gui/image/qppmhandler.cpp18
15 files changed, 57 insertions, 1523 deletions
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri
index 01e48c17dd..0c033609c4 100644
--- a/src/gui/image/image.pri
+++ b/src/gui/image/image.pri
@@ -14,7 +14,6 @@ HEADERS += \
image/qpaintengine_pic_p.h \
image/qpicture.h \
image/qpicture_p.h \
- image/qpictureformatplugin.h \
image/qpixmap.h \
image/qpixmap_raster_p.h \
image/qpixmap_blitter_p.h \
@@ -38,7 +37,6 @@ SOURCES += \
image/qimagewriter.cpp \
image/qpaintengine_pic.cpp \
image/qpicture.cpp \
- image/qpictureformatplugin.cpp \
image/qpixmap.cpp \
image/qpixmapcache.cpp \
image/qplatformpixmap.cpp \
@@ -59,9 +57,6 @@ win32:!winrt: SOURCES += image/qpixmap_win.cpp
darwin: OBJECTIVE_SOURCES += image/qimage_darwin.mm
-NO_PCH_SOURCES += image/qimage_compat.cpp
-false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator
-
# Built-in image format support
HEADERS += \
image/qbmphandler_p.h \
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
index 32b6131309..d447faaceb 100644
--- a/src/gui/image/qbmphandler.cpp
+++ b/src/gui/image/qbmphandler.cpp
@@ -777,9 +777,9 @@ bool QBmpHandler::write(const QImage &img)
}
int nbits;
- int bpl_bmp;
+ qsizetype bpl_bmp;
// Calculate a minimum bytes-per-line instead of using whatever value this QImage is using internally.
- int bpl = ((image.width() * image.depth() + 31) >> 5) << 2;
+ qsizetype bpl = ((image.width() * image.depth() + 31) >> 5) << 2;
if (image.depth() == 8 && image.colorCount() <= 16) {
bpl_bmp = (((bpl+1)/2+3)/4)*4;
@@ -791,6 +791,8 @@ bool QBmpHandler::write(const QImage &img)
bpl_bmp = bpl;
nbits = image.depth();
}
+ if (qsizetype(int(bpl_bmp)) != bpl_bmp)
+ return false;
if (m_format == DibFormat) {
QDataStream dibStream(device());
@@ -813,6 +815,8 @@ bool QBmpHandler::write(const QImage &img)
bf.bfReserved2 = 0;
bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.colorCount() * 4;
bf.bfSize = bf.bfOffBits + bpl_bmp*image.height();
+ if (qsizetype(bf.bfSize) != bf.bfOffBits + bpl_bmp*image.height())
+ return false;
s << bf;
// write image
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 9a5aefbfed..684051786d 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -781,7 +781,7 @@ QImage::QImage(const QSize &size, Format format)
-QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction, void *cleanupInfo)
+QImageData *QImageData::create(uchar *data, int width, int height, qsizetype bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction, void *cleanupInfo)
{
if (width <= 0 || height <= 0 || !data || format == QImage::Format_Invalid)
return nullptr;
@@ -793,7 +793,7 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm
if (bpl > 0) {
// can't overflow, because has calculateImageParameters already done this multiplication
- const int min_bytes_per_line = (width * depth + 7)/8;
+ const qsizetype min_bytes_per_line = (qsizetype(width) * depth + 7)/8;
if (bpl < min_bytes_per_line)
return nullptr;
@@ -894,13 +894,17 @@ QImage::QImage(const uchar* data, int width, int height, Format format, QImageCl
initially empty and must be sufficiently expanded with
setColorCount() or setColorTable() before the image is used.
*/
+
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
+QImage::QImage(uchar *data, int width, int height, qsizetype bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo)
+#else
QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo)
+#endif
:QPaintDevice()
{
d = QImageData::create(data, width, height, bytesPerLine, format, false, cleanupFunction, cleanupInfo);
}
-
/*!
Constructs an image with the given \a width, \a height and \a
format, that uses an existing memory buffer, \a data. The \a width
@@ -926,7 +930,11 @@ QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format form
data being changed.
*/
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
+QImage::QImage(const uchar *data, int width, int height, qsizetype bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo)
+#else
QImage::QImage(const uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo)
+#endif
:QPaintDevice()
{
d = QImageData::create(const_cast<uchar*>(data), width, height, bytesPerLine, format, true, cleanupFunction, cleanupInfo);
@@ -1165,7 +1173,7 @@ QImage QImage::copy(const QRect& r) const
// Qt for Embedded Linux can create images with non-default bpl
// make sure we don't crash.
if (image.d->nbytes != d->nbytes) {
- int bpl = qMin(bytesPerLine(), image.bytesPerLine());
+ qsizetype bpl = qMin(bytesPerLine(), image.bytesPerLine());
for (int i = 0; i < height(); i++)
memcpy(image.scanLine(i), scanLine(i), bpl);
} else
@@ -1224,7 +1232,7 @@ QImage QImage::copy(const QRect& r) const
if (byteAligned) {
const uchar *src = d->data + ((x * d->depth) >> 3) + y * d->bytes_per_line;
uchar *dest = image.d->data + ((dx * d->depth) >> 3) + dy * image.d->bytes_per_line;
- const int bytes_to_copy = (pixels_to_copy * d->depth) >> 3;
+ const qsizetype bytes_to_copy = (qsizetype(pixels_to_copy) * d->depth) >> 3;
for (int i = 0; i < lines_to_copy; ++i) {
memcpy(dest, src, bytes_to_copy);
src += d->bytes_per_line;
@@ -1381,11 +1389,7 @@ int QImage::colorCount() const
\sa colorTable(), setColor(), {QImage#Image Transformations}{Image
Transformations}
*/
-#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
void QImage::setColorTable(const QVector<QRgb> &colors)
-#else
-void QImage::setColorTable(const QVector<QRgb> colors)
-#endif
{
if (!d)
return;
@@ -1395,11 +1399,7 @@ void QImage::setColorTable(const QVector<QRgb> colors)
if (!d)
return;
-#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
d->colortable = colors;
-#else
- d->colortable = std::move(const_cast<QVector<QRgb>&>(colors));
-#endif
d->has_alpha_clut = false;
for (int i = 0; i < d->colortable.size(); ++i) {
if (qAlpha(d->colortable.at(i)) != 255) {
@@ -1472,25 +1472,6 @@ void QImage::setDevicePixelRatio(qreal scaleFactor)
d->devicePixelRatio = scaleFactor;
}
-#if QT_DEPRECATED_SINCE(5, 10)
-/*!
- \since 4.6
- \obsolete
- Returns the number of bytes occupied by the image data.
-
- Note this method should never be called on an image larger than 2 gigabytes.
- Instead use sizeInBytes().
-
- \sa sizeInBytes(), bytesPerLine(), bits(), {QImage#Image Information}{Image
- Information}
-*/
-int QImage::byteCount() const
-{
- Q_ASSERT(!d || d->nbytes < std::numeric_limits<int>::max());
- return d ? int(d->nbytes) : 0;
-}
-#endif
-
/*!
\since 5.10
Returns the image data size in bytes.
@@ -1510,17 +1491,10 @@ qsizetype QImage::sizeInBytes() const
\sa scanLine()
*/
-#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
qsizetype QImage::bytesPerLine() const
{
return d ? d->bytes_per_line : 0;
}
-#else
-int QImage::bytesPerLine() const
-{
- return d ? d->bytes_per_line : 0;
-}
-#endif
/*!
@@ -1924,11 +1898,11 @@ void QImage::invertPixels(InvertMode mode)
if (depth() < 32) {
// This assumes no alpha-channel as the only formats with non-premultipled alpha are 32bit.
- int bpl = (d->width * d->depth + 7) / 8;
+ qsizetype bpl = (qsizetype(d->width) * d->depth + 7) / 8;
int pad = d->bytes_per_line - bpl;
uchar *sl = d->data;
for (int y=0; y<d->height; ++y) {
- for (int x=0; x<bpl; ++x)
+ for (qsizetype x=0; x<bpl; ++x)
*sl++ ^= 0xff;
sl += pad;
}
@@ -4068,71 +4042,10 @@ void QImage::setText(const QString &key, const QString &value)
}
/*!
- \fn QString QImage::text(const char* key, const char* language) const
- \obsolete
-
- Returns the text recorded for the given \a key in the given \a
- language, or in a default language if \a language is \nullptr.
-
- Use text() instead.
-
- The language the text is recorded in is no longer relevant since
- the text is always set using QString and UTF-8 representation.
-*/
-
-/*!
- \fn QString QImage::text(const QImageTextKeyLang& keywordAndLanguage) const
- \overload
- \obsolete
-
- Returns the text recorded for the given \a keywordAndLanguage.
-
- Use text() instead.
-
- The language the text is recorded in is no longer relevant since
- the text is always set using QString and UTF-8 representation.
-*/
-
-/*!
- \fn void QImage::setText(const char* key, const char* language, const QString& text)
- \obsolete
-
- Sets the image text to the given \a text and associate it with the
- given \a key. The text is recorded in the specified \a language,
- or in a default language if \a language is \nullptr.
-
- Use setText() instead.
-
- The language the text is recorded in is no longer relevant since
- the text is always set using QString and UTF-8 representation.
-
- \omit
- Records string \a for the keyword \a key. The \a key should be
- a portable keyword recognizable by other software - some suggested
- values can be found in
- \l{http://www.libpng.org/pub/png/spec/1.2/png-1.2-pdg.html#C.Anc-text}
- {the PNG specification}. \a s can be any text. \a lang should
- specify the language code (see
- \l{http://www.rfc-editor.org/rfc/rfc1766.txt}{RFC 1766}) or \nullptr.
- \endomit
-*/
-
-/*
- Sets the image bits to the \a pixmap contents and returns a
- reference to the image.
-
- If the image shares data with other images, it will first
- dereference the shared data.
-
- Makes a call to QPixmap::convertToImage().
-*/
-
-/*!
\internal
Used by QPainter to retrieve a paint engine for the image.
*/
-
QPaintEngine *QImage::paintEngine() const
{
if (!d)
@@ -4264,8 +4177,8 @@ int QImage::metric(PaintDeviceMetric metric) const
trigy += m12;
// END OF MACRO
bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth,
- uchar *dptr, int dbpl, int p_inc, int dHeight,
- const uchar *sptr, int sbpl, int sWidth, int sHeight)
+ uchar *dptr, qsizetype dbpl, int p_inc, int dHeight,
+ const uchar *sptr, qsizetype sbpl, int sWidth, int sHeight)
{
int m11 = int(trueMat.m11()*4096.0);
int m12 = int(trueMat.m12()*4096.0);
@@ -4378,22 +4291,6 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth
#undef IWX_LSB
#undef IWX_PIX
-/*! \fn int QImage::serialNumber() const
- \obsolete
- Returns a number that identifies the contents of this
- QImage object. Distinct QImage objects can only have the same
- serial number if they refer to the same contents (but they don't
- have to).
-
- Use cacheKey() instead.
-
- \warning The serial number doesn't necessarily change when the
- image is altered. This means that it may be dangerous to use
- it as a cache key.
-
- \sa operator==()
-*/
-
/*!
Returns a number that identifies the contents of this QImage
object. Distinct QImage objects can only have the same key if they
@@ -4823,7 +4720,7 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
int bpp = depth();
- int sbpl = bytesPerLine();
+ qsizetype sbpl = bytesPerLine();
const uchar *sptr = bits();
QImage::Format target_format = d->format;
@@ -4878,7 +4775,7 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
// create target image (some of the code is from QImage::copy())
int type = format() == Format_Mono ? QT_XFORM_TYPE_MSBFIRST : QT_XFORM_TYPE_LSBFIRST;
- int dbpl = dImage.bytesPerLine();
+ qsizetype dbpl = dImage.bytesPerLine();
qt_xForm_helper(mat, 0, type, bpp, dImage.bits(), dbpl, 0, hd, sptr, sbpl, ws, hs);
}
copyMetadata(dImage.d, d);
@@ -5099,50 +4996,6 @@ QDebug operator<<(QDebug dbg, const QImage &i)
}
#endif
-/*!
- \fn void QImage::setNumColors(int n)
- \obsolete
-
- Resizes the color table to contain \a n entries.
-
- \sa setColorCount()
- */
-
-/*!
- \fn int QImage::numBytes() const
- \obsolete
-
- Returns the number of bytes occupied by the image data.
-
- \sa sizeInBytes()
- */
-
-/*!
- \fn QStringList QImage::textLanguages() const
- \obsolete
-
- Returns the language identifiers for which some texts are recorded.
- Note that if you want to iterate over the list, you should iterate over a copy.
-
- The language the text is recorded in is no longer relevant since the text is
- always set using QString and UTF-8 representation.
-
- \sa textKeys()
- */
-
-/*!
- \fn QList<QImageTextKeyLang> QImage::textList() const
- \obsolete
-
- Returns a list of QImageTextKeyLang objects that enumerate all the texts
- key/language pairs set for this image.
-
- The language the text is recorded in is no longer relevant since the text
- is always set using QString and UTF-8 representation.
-
- \sa textKeys()
- */
-
static Q_CONSTEXPR QPixelFormat pixelformats[] = {
//QImage::Format_Invalid:
QPixelFormat(),
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 56824e5ee7..5a1524b419 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -50,10 +50,6 @@
#include <QtCore/qrect.h>
#include <QtCore/qstring.h>
-#if QT_DEPRECATED_SINCE(5, 0)
-#include <QtCore/qstringlist.h>
-#endif
-
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(CGImage);
#endif
@@ -68,31 +64,9 @@ class QMatrix;
class QStringList;
class QTransform;
class QVariant;
-template <class T> class QList;
template <class T> class QVector;
struct QImageData;
-class QImageDataMisc; // internal
-#if QT_DEPRECATED_SINCE(5, 0)
-class QImageTextKeyLang {
-public:
- QT_DEPRECATED QImageTextKeyLang(const char* k, const char* l) : key(k), lang(l) { }
- QT_DEPRECATED QImageTextKeyLang() { }
-
- QByteArray key;
- QByteArray lang;
-
- bool operator< (const QImageTextKeyLang& other) const
- { return key < other.key || (key==other.key && lang < other.lang); }
- bool operator== (const QImageTextKeyLang& other) const
- { return key==other.key && lang==other.lang; }
- inline bool operator!= (const QImageTextKeyLang &other) const
- { return !operator==(other); }
-private:
- friend class QImage;
- QImageTextKeyLang(bool /*dummy*/) {}
-};
-#endif
typedef void (*QImageCleanupFunction)(void*);
@@ -143,8 +117,13 @@ public:
QImage(int width, int height, Format format);
QImage(uchar *data, int width, int height, Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr);
QImage(const uchar *data, int width, int height, Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr);
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
+ QImage(uchar *data, int width, int height, qsizetype bytesPerLine, Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr);
+ QImage(const uchar *data, int width, int height, qsizetype bytesPerLine, Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr);
+#else
QImage(uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr);
QImage(const uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr);
+#endif
#ifndef QT_NO_IMAGEFORMAT_XPM
explicit QImage(const char * const xpm[]);
@@ -179,7 +158,6 @@ public:
Format format() const;
-#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QIMAGE_COMPAT_CPP)
Q_REQUIRED_RESULT Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const &
{ return convertToFormat_helper(f, flags); }
Q_REQUIRED_RESULT Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) &&
@@ -189,9 +167,6 @@ public:
else
return convertToFormat_helper(f, flags);
}
-#else
- Q_REQUIRED_RESULT QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const;
-#endif
Q_REQUIRED_RESULT QImage convertToFormat(Format f, const QVector<QRgb> &colorTable, Qt::ImageConversionFlags flags = Qt::AutoColor) const;
bool reinterpretAsFormat(Format f);
@@ -217,19 +192,12 @@ public:
const uchar *bits() const;
const uchar *constBits() const;
-#if QT_DEPRECATED_SINCE(5, 10)
- QT_DEPRECATED_X("Use sizeInBytes") int byteCount() const;
-#endif
qsizetype sizeInBytes() const;
uchar *scanLine(int);
const uchar *scanLine(int) const;
const uchar *constScanLine(int) const;
-#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
qsizetype bytesPerLine() const;
-#else
- int bytesPerLine() const;
-#endif
bool valid(int x, int y) const;
bool valid(const QPoint &pt) const;
@@ -250,11 +218,7 @@ public:
void setPixelColor(const QPoint &pt, const QColor &c);
QVector<QRgb> colorTable() const;
-#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
void setColorTable(const QVector<QRgb> &colors);
-#else
- void setColorTable(const QVector<QRgb> colors);
-#endif
qreal devicePixelRatio() const;
void setDevicePixelRatio(qreal scaleFactor);
@@ -291,7 +255,6 @@ public:
#endif // QT_DEPRECATED_SINCE(5, 15)
QImage transformed(const QTransform &matrix, Qt::TransformationMode mode = Qt::FastTransformation) const;
static QTransform trueMatrix(const QTransform &, int w, int h);
-#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QIMAGE_COMPAT_CPP)
QImage mirrored(bool horizontally = false, bool vertically = true) const &
{ return mirrored_helper(horizontally, vertically); }
QImage &&mirrored(bool horizontally = false, bool vertically = true) &&
@@ -300,10 +263,6 @@ public:
{ return rgbSwapped_helper(); }
QImage &&rgbSwapped() &&
{ rgbSwapped_inplace(); return std::move(*this); }
-#else
- QImage mirrored(bool horizontally = false, bool vertically = true) const;
- QImage rgbSwapped() const;
-#endif
void invertPixels(InvertMode = InvertRgb);
QColorSpace colorSpace() const;
@@ -326,9 +285,6 @@ public:
inline static QImage fromData(const QByteArray &data, const char *format = nullptr)
{ return fromData(reinterpret_cast<const uchar *>(data.constData()), data.size(), format); }
-#if QT_DEPRECATED_SINCE(5, 0)
- QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; }
-#endif
qint64 cacheKey() const;
QPaintEngine *paintEngine() const override;
@@ -354,20 +310,6 @@ public:
CGImageRef toCGImage() const Q_DECL_CF_RETURNS_RETAINED;
#endif
-#if QT_DEPRECATED_SINCE(5, 0)
- QT_DEPRECATED inline QString text(const char *key, const char *lang = nullptr) const;
- QT_DEPRECATED inline QList<QImageTextKeyLang> textList() const;
- QT_DEPRECATED inline QStringList textLanguages() const;
- QT_DEPRECATED inline QString text(const QImageTextKeyLang&) const;
- QT_DEPRECATED inline void setText(const char* key, const char* lang, const QString&);
-#endif
-
-#if QT_DEPRECATED_SINCE(5, 0)
- QT_DEPRECATED inline int numColors() const;
- QT_DEPRECATED inline void setNumColors(int);
- QT_DEPRECATED inline int numBytes() const;
-#endif
-
protected:
virtual int metric(PaintDeviceMetric metric) const override;
QImage mirrored_helper(bool horizontal, bool vertical) const;
@@ -402,99 +344,6 @@ inline void QImage::setPixel(const QPoint &pt, uint index_or_rgb) { setPixel(pt.
inline QColor QImage::pixelColor(const QPoint &pt) const { return pixelColor(pt.x(), pt.y()); }
inline void QImage::setPixelColor(const QPoint &pt, const QColor &c) { setPixelColor(pt.x(), pt.y(), c); }
-#if QT_DEPRECATED_SINCE(5, 0)
-
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-
-inline QString QImage::text(const char* key, const char* lang) const
-{
- if (!d)
- return QString();
- QString k = QString::fromLatin1(key);
- if (lang && *lang)
- k += QLatin1Char('/') + QString::fromLatin1(lang);
- return text(k);
-}
-
-inline QList<QImageTextKeyLang> QImage::textList() const
-{
- QList<QImageTextKeyLang> imageTextKeys;
- if (!d)
- return imageTextKeys;
- QStringList keys = textKeys();
- for (int i = 0; i < keys.size(); ++i) {
- int index = keys.at(i).indexOf(QLatin1Char('/'));
- if (index > 0) {
- QImageTextKeyLang tkl(true);
- tkl.key = keys.at(i).left(index).toLatin1();
- tkl.lang = keys.at(i).mid(index+1).toLatin1();
- imageTextKeys += tkl;
- }
- }
-
- return imageTextKeys;
-}
-
-inline QStringList QImage::textLanguages() const
-{
- if (!d)
- return QStringList();
- QStringList keys = textKeys();
- QStringList languages;
- for (int i = 0; i < keys.size(); ++i) {
- int index = keys.at(i).indexOf(QLatin1Char('/'));
- if (index > 0)
- languages += keys.at(i).mid(index+1);
- }
-
- return languages;
-}
-
-inline QString QImage::text(const QImageTextKeyLang&kl) const
-{
- if (!d)
- return QString();
- QString k = QString::fromLatin1(kl.key.constData());
- if (!kl.lang.isEmpty())
- k += QLatin1Char('/') + QString::fromLatin1(kl.lang.constData());
- return text(k);
-}
-
-inline void QImage::setText(const char* key, const char* lang, const QString &s)
-{
- if (!d)
- return;
- detach();
-
- // In case detach() ran out of memory
- if (!d)
- return;
-
- QString k = QString::fromLatin1(key);
- if (lang && *lang)
- k += QLatin1Char('/') + QString::fromLatin1(lang);
- setText(k, s);
-}
-
-QT_WARNING_POP
-
-inline int QImage::numColors() const
-{
- return colorCount();
-}
-
-inline void QImage::setNumColors(int n)
-{
- setColorCount(n);
-}
-
-inline int QImage::numBytes() const
-{
- return int(sizeInBytes());
-}
-#endif
-
// QImage stream functions
#if !defined(QT_NO_DATASTREAM)
diff --git a/src/gui/image/qimage_compat.cpp b/src/gui/image/qimage_compat.cpp
deleted file mode 100644
index ba31a9ac9b..0000000000
--- a/src/gui/image/qimage_compat.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifdef QIMAGE_H
-# error "This file cannot be used with precompiled headers"
-#endif
-#define QT_COMPILING_QIMAGE_COMPAT_CPP
-
-#include "qimage.h"
-
-QT_BEGIN_NAMESPACE
-
-// These implementations must be the same as the inline versions in qimage.h
-
-QImage QImage::convertToFormat(Format f, Qt::ImageConversionFlags flags) const
-{
- return convertToFormat_helper(f, flags);
-}
-
-QImage QImage::mirrored(bool horizontally, bool vertically) const
-{
- return mirrored_helper(horizontally, vertically);
-}
-
-QImage QImage::rgbSwapped() const
-{
- return rgbSwapped_helper();
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index 0930955f5a..6f6f626858 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -67,7 +67,7 @@ struct Q_GUI_EXPORT QImageData { // internal image data
QImageData();
~QImageData();
static QImageData *create(const QSize &size, QImage::Format format);
- static QImageData *create(uchar *data, int w, int h, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr);
+ static QImageData *create(uchar *data, int w, int h, qsizetype bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr);
QAtomicInt ref;
@@ -140,7 +140,7 @@ QImageData::calculateImageParameters(qsizetype width, qsizetype height, qsizetyp
qsizetype dummy;
if (mul_overflow(height, qsizetype(sizeof(uchar *)), &dummy))
return invalid; // why is this here?
-#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
+#if 1 || QT_VERSION < QT_VERSION_CHECK(6,0,0) // ### can only fix this if QImage dimensions are not int anymore
// Disallow images where width * depth calculations might overflow
if (width > (INT_MAX - 31) / depth)
return invalid;
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index 3a32cc7f15..d469ac8aae 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -264,14 +264,14 @@ void QPicture::setData(const char* data, uint size)
\sa save()
*/
-bool QPicture::load(const QString &fileName, const char *format)
+bool QPicture::load(const QString &fileName)
{
QFile f(fileName);
if (!f.open(QIODevice::ReadOnly)) {
operator=(QPicture());
return false;
}
- return load(&f, format);
+ return load(&f);
}
/*!
@@ -280,21 +280,8 @@ bool QPicture::load(const QString &fileName, const char *format)
\a dev is the device to use for loading.
*/
-bool QPicture::load(QIODevice *dev, const char *format)
+bool QPicture::load(QIODevice *dev)
{
- if(format) {
-#ifndef QT_NO_PICTUREIO
- QPictureIO io(dev, format);
- if (io.read()) {
- operator=(io.picture());
- return true;
- }
-#endif
- qWarning("QPicture::load: No such picture format: %s", format);
- operator=(QPicture());
- return false;
- }
-
detach();
QByteArray a = dev->readAll();
@@ -312,7 +299,7 @@ bool QPicture::load(QIODevice *dev, const char *format)
\sa load()
*/
-bool QPicture::save(const QString &fileName, const char *format)
+bool QPicture::save(const QString &fileName)
{
if (paintingActive()) {
qWarning("QPicture::save: still being painted on. "
@@ -320,27 +307,10 @@ bool QPicture::save(const QString &fileName, const char *format)
return false;
}
-
- if(format) {
-#ifndef QT_NO_PICTUREIO
- QPictureIO io(fileName, format);
- bool result = io.write();
- if (result) {
- operator=(io.picture());
- } else if (format)
-#else
- bool result = false;
-#endif
- {
- qWarning("QPicture::save: No such picture format: %s", format);
- }
- return result;
- }
-
QFile f(fileName);
if (!f.open(QIODevice::WriteOnly))
return false;
- return save(&f, format);
+ return save(&f);
}
/*!
@@ -349,7 +319,7 @@ bool QPicture::save(const QString &fileName, const char *format)
\a dev is the device to use for saving.
*/
-bool QPicture::save(QIODevice *dev, const char *format)
+bool QPicture::save(QIODevice *dev)
{
if (paintingActive()) {
qWarning("QPicture::save: still being painted on. "
@@ -357,22 +327,6 @@ bool QPicture::save(QIODevice *dev, const char *format)
return false;
}
- if(format) {
-#ifndef QT_NO_PICTUREIO
- QPictureIO io(dev, format);
- bool result = io.write();
- if (result) {
- operator=(io.picture());
- } else if (format)
-#else
- bool result = false;
-#endif
- {
- qWarning("QPicture::save: No such picture format: %s", format);
- }
- return result;
- }
-
dev->write(d_func()->pictb.buffer(), d_func()->pictb.buffer().size());
return true;
}
@@ -1189,780 +1143,6 @@ QDataStream &operator>>(QDataStream &s, QPicture &r)
}
#endif // QT_NO_DATASTREAM
-
-#ifndef QT_NO_PICTUREIO
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include "qregexp.h"
-#include "qpictureformatplugin.h"
-QT_END_INCLUDE_NAMESPACE
-
-#if QT_DEPRECATED_SINCE(5, 10)
-/*!
- \obsolete
-
- Returns a string that specifies the picture format of the file \a
- fileName, or \nullptr if the file cannot be read or if the format
- is not recognized.
-
- \sa load(), save()
-*/
-
-const char* QPicture::pictureFormat(const QString &fileName)
-{
- const QByteArray format = QPictureIO::pictureFormat(fileName);
- // This function returns a const char * from a QByteArray.
- // Double check that the QByteArray is not detached, otherwise
- // we would return a dangling pointer.
- Q_ASSERT(!format.isDetached());
- return format;
-}
-
-/*!
- \obsolete
-
- Returns a list of picture formats that are supported for picture
- input.
-
- \sa outputFormats(), inputFormatList(), QPictureIO
-*/
-QList<QByteArray> QPicture::inputFormats()
-{
- return QPictureIO::inputFormats();
-}
-
-static QStringList qToStringList(const QList<QByteArray> &arr)
-{
- QStringList list;
- const int count = arr.count();
- list.reserve(count);
- for (int i = 0; i < count; ++i)
- list.append(QString::fromLatin1(arr.at(i)));
- return list;
-}
-
-/*!
- \obsolete
-
- Returns a list of picture formats that are supported for picture
- input.
-
- Note that if you want to iterate over the list, you should iterate
- over a copy, e.g.
- \snippet picture/picture.cpp 2
-
- \sa outputFormatList(), inputFormats(), QPictureIO
-*/
-QStringList QPicture::inputFormatList()
-{
- return qToStringList(QPictureIO::inputFormats());
-}
-
-
-/*!
- \obsolete
-
- Returns a list of picture formats that are supported for picture
- output.
-
- Note that if you want to iterate over the list, you should iterate
- over a copy, e.g.
- \snippet picture/picture.cpp 3
-
- \sa inputFormatList(), outputFormats(), QPictureIO
-*/
-QStringList QPicture::outputFormatList()
-{
- return qToStringList(QPictureIO::outputFormats());
-}
-
-/*!
- \obsolete
-
- Returns a list of picture formats that are supported for picture
- output.
-
- \sa inputFormats(), outputFormatList(), QPictureIO
-*/
-QList<QByteArray> QPicture::outputFormats()
-{
- return QPictureIO::outputFormats();
-}
-#endif // QT_DEPRECATED_SINCE(5, 10)
-
-/*****************************************************************************
- QPictureIO member functions
- *****************************************************************************/
-
-/*!
- \obsolete
-
- \class QPictureIO
-
- \brief The QPictureIO class contains parameters for loading and
- saving pictures.
-
- \ingroup painting
- \ingroup io
- \inmodule QtGui
-
- QPictureIO contains a QIODevice object that is used for picture data
- I/O. The programmer can install new picture file formats in addition
- to those that Qt provides.
-
- You don't normally need to use this class; QPicture::load(),
- QPicture::save().
-
- \sa QPicture, QPixmap, QFile
-*/
-
-struct QPictureIOData
-{
- QPicture pi; // picture
- int iostat; // IO status
- QByteArray frmt; // picture format
- QIODevice *iodev; // IO device
- QString fname; // file name
- QString descr; // picture description
- const char *parameters;
- int quality;
- float gamma;
-};
-
-/*!
- Constructs a QPictureIO object with all parameters set to zero.
-*/
-
-QPictureIO::QPictureIO()
-{
- init();
-}
-
-/*!
- Constructs a QPictureIO object with the I/O device \a ioDevice and a
- \a format tag.
-*/
-
-QPictureIO::QPictureIO(QIODevice *ioDevice, const char *format)
-{
- init();
- d->iodev = ioDevice;
- d->frmt = format;
-}
-
-/*!
- Constructs a QPictureIO object with the file name \a fileName and a
- \a format tag.
-*/
-
-QPictureIO::QPictureIO(const QString &fileName, const char* format)
-{
- init();
- d->frmt = format;
- d->fname = fileName;
-}
-
-/*!
- Contains initialization common to all QPictureIO constructors.
-*/
-
-void QPictureIO::init()
-{
- d = new QPictureIOData();
- d->parameters = nullptr;
- d->quality = -1; // default quality of the current format
- d->gamma=0.0f;
- d->iostat = 0;
- d->iodev = nullptr;
-}
-
-/*!
- Destroys the object and all related data.
-*/
-
-QPictureIO::~QPictureIO()
-{
- if (d->parameters)
- delete [] d->parameters;
- delete d;
-}
-
-
-/*****************************************************************************
- QPictureIO picture handler functions
- *****************************************************************************/
-
-class QPictureHandler
-{
-public:
- QPictureHandler(const char *f, const char *h, const QByteArray& fl,
- picture_io_handler r, picture_io_handler w);
- QByteArray format; // picture format
- QRegExp header; // picture header pattern
- enum TMode { Untranslated=0, TranslateIn, TranslateInOut } text_mode;
- picture_io_handler read_picture; // picture read function
- picture_io_handler write_picture; // picture write function
- bool obsolete; // support not "published"
-};
-
-QPictureHandler::QPictureHandler(const char *f, const char *h, const QByteArray& fl,
- picture_io_handler r, picture_io_handler w)
- : format(f), header(QString::fromLatin1(h))
-{
- text_mode = Untranslated;
- if (fl.contains('t'))
- text_mode = TranslateIn;
- else if (fl.contains('T'))
- text_mode = TranslateInOut;
- obsolete = fl.contains('O');
- read_picture = r;
- write_picture = w;
-}
-
-typedef QList<QPictureHandler *> QPHList;
-Q_GLOBAL_STATIC(QPHList, pictureHandlers)
-
-void qt_init_picture_plugins()
-{
- typedef QMultiMap<int, QString> PluginKeyMap;
- typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
-
- static QBasicMutex mutex;
- const auto locker = qt_scoped_lock(mutex);
- static QFactoryLoader loader(QPictureFormatInterface_iid,
- QStringLiteral("/pictureformats"));
-
- const PluginKeyMap keyMap = loader.keyMap();
- const PluginKeyMapConstIterator cend = keyMap.constEnd();
- for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) {
- if (QPictureFormatPlugin *format = qobject_cast<QPictureFormatPlugin*>(loader.instance(it.key())))
- format->installIOHandler(it.value());
- }
-}
-
-static void cleanup()
-{
- // make sure that picture handlers are delete before plugin manager
- if (QPHList *list = pictureHandlers()) {
- qDeleteAll(*list);
- list->clear();
- }
-}
-
-void qt_init_picture_handlers() // initialize picture handlers
-{
- static QBasicAtomicInt done = Q_BASIC_ATOMIC_INITIALIZER(0);
- if (done.testAndSetRelaxed(0, 1)) {
- qAddPostRoutine(cleanup);
- }
-}
-
-static QPictureHandler *get_picture_handler(const char *format)
-{ // get pointer to handler
- qt_init_picture_handlers();
- qt_init_picture_plugins();
- if (QPHList *list = pictureHandlers()) {
- for (int i = 0; i < list->size(); ++i) {
- if (list->at(i)->format == format)
- return list->at(i);
- }
- }
- return nullptr; // no such handler
-}
-
-
-/*!
- Defines a picture I/O handler for the picture format called \a
- format, which is recognized using the regular
- expression defined in \a header, read using \a readPicture and
- written using \a writePicture.
-
- \a flags is a string of single-character flags for this format.
- The only flag defined currently is T (upper case), so the only
- legal value for \a flags are "T" and the empty string. The "T"
- flag means that the picture file is a text file, and Qt should treat
- all newline conventions as equivalent. (XPM files and some PPM
- files are text files for example.)
-
- \a format is used to select a handler to write a QPicture; \a header
- is used to select a handler to read an picture file.
-
- If \a readPicture is \nullptr, the QPictureIO will not be able
- to read pictures in \a format. If \a writePicture is \nullptr,
- the QPictureIO will not be able to write pictures in \a format. If
- both are null, the QPictureIO object is valid but useless.
-
- Example:
- \snippet picture/picture.cpp 6
- \codeline
- \snippet picture/picture.cpp 7
- \codeline
- \snippet picture/picture.cpp 8
-
- Before the regular expression test, all the 0 bytes in the file header are
- converted to 1 bytes. This is done because when Qt was ASCII-based, QRegExp
- could not handle 0 bytes in strings.
-
- The regexp is only applied on the first 14 bytes of the file.
-
- (Note that if one handlerIO supports writing a format and another
- supports reading it, Qt supports both reading and writing. If two
- handlers support the same operation, Qt chooses one arbitrarily.)
-*/
-
-void QPictureIO::defineIOHandler(const char *format,
- const char *header,
- const char *flags,
- picture_io_handler readPicture,
- picture_io_handler writePicture)
-{
- qt_init_picture_handlers();
- if (QPHList *list = pictureHandlers()) {
- QPictureHandler *p;
- p = new QPictureHandler(format, header, QByteArray(flags), readPicture, writePicture);
- list->prepend(p);
- }
-}
-
-
-/*****************************************************************************
- QPictureIO normal member functions
- *****************************************************************************/
-
-/*!
- Returns the picture currently set.
-
- \sa setPicture()
-*/
-const QPicture &QPictureIO::picture() const { return d->pi; }
-
-/*!
- Returns the picture's IO status. A non-zero value indicates an
- error, whereas 0 means that the IO operation was successful.
-
- \sa setStatus()
-*/
-int QPictureIO::status() const { return d->iostat; }
-
-/*!
- Returns the picture format string or \nullptr if no format has been
- explicitly set.
-*/
-const char *QPictureIO::format() const { return d->frmt; }
-
-/*!
- Returns the IO device currently set.
-
- \sa setIODevice()
-*/
-QIODevice *QPictureIO::ioDevice() const { return d->iodev; }
-
-/*!
- Returns the file name currently set.
-
- \sa setFileName()
-*/
-QString QPictureIO::fileName() const { return d->fname; }
-
-
-/*!
- Returns the picture description string.
-
- \sa setDescription()
-*/
-QString QPictureIO::description() const { return d->descr; }
-
-/*!
- Sets the picture to \a picture.
-
- \sa picture()
-*/
-void QPictureIO::setPicture(const QPicture &picture)
-{
- d->pi = picture;
-}
-
-/*!
- Sets the picture IO status to \a status. A non-zero value indicates
- an error, whereas 0 means that the IO operation was successful.
-
- \sa status()
-*/
-void QPictureIO::setStatus(int status)
-{
- d->iostat = status;
-}
-
-/*!
- Sets the picture format to \a format for the picture to be read or
- written.
-
- It is necessary to specify a format before writing an picture, but
- it is not necessary to specify a format before reading an picture.
-
- If no format has been set, Qt guesses the picture format before
- reading it. If a format is set the picture will only be read if it
- has that format.
-
- \sa read(), write(), format()
-*/
-void QPictureIO::setFormat(const char *format)
-{
- d->frmt = format;
-}
-
-/*!
- Sets the IO device to be used for reading or writing an picture.
-
- Setting the IO device allows pictures to be read/written to any
- block-oriented QIODevice.
-
- If \a ioDevice is not null, this IO device will override file name
- settings.
-
- \sa setFileName()
-*/
-void QPictureIO::setIODevice(QIODevice *ioDevice)
-{
- d->iodev = ioDevice;
-}
-
-/*!
- Sets the name of the file to read or write an picture from to \a
- fileName.
-
- \sa setIODevice()
-*/
-void QPictureIO::setFileName(const QString &fileName)
-{
- d->fname = fileName;
-}
-
-/*!
- Returns the quality of the written picture, related to the
- compression ratio.
-
- \sa setQuality(), QPicture::save()
-*/
-int QPictureIO::quality() const
-{
- return d->quality;
-}
-
-/*!
- Sets the quality of the written picture to \a q, related to the
- compression ratio.
-
- \a q must be in the range -1..100. Specify 0 to obtain small
- compressed files, 100 for large uncompressed files. (-1 signifies
- the default compression.)
-
- \sa quality(), QPicture::save()
-*/
-
-void QPictureIO::setQuality(int q)
-{
- d->quality = q;
-}
-
-/*!
- Returns the picture's parameters string.
-
- \sa setParameters()
-*/
-
-const char *QPictureIO::parameters() const
-{
- return d->parameters;
-}
-
-/*!
- Sets the picture's parameter string to \a parameters. This is for
- picture handlers that require special parameters.
-
- Although the current picture formats supported by Qt ignore the
- parameters string, it may be used in future extensions or by
- contributions (for example, JPEG).
-
- \sa parameters()
-*/
-
-void QPictureIO::setParameters(const char *parameters)
-{
- if (d->parameters)
- delete [] d->parameters;
- d->parameters = qstrdup(parameters);
-}
-
-/*!
- Sets the gamma value at which the picture will be viewed to \a
- gamma. If the picture format stores a gamma value for which the
- picture is intended to be used, then this setting will be used to
- modify the picture. Setting to 0.0 will disable gamma correction
- (i.e. any specification in the file will be ignored).
-
- The default value is 0.0.
-
- \sa gamma()
-*/
-void QPictureIO::setGamma(float gamma)
-{
- d->gamma=gamma;
-}
-
-/*!
- Returns the gamma value at which the picture will be viewed.
-
- \sa setGamma()
-*/
-float QPictureIO::gamma() const
-{
- return d->gamma;
-}
-
-/*!
- Sets the picture description string for picture handlers that support
- picture descriptions to \a description.
-
- Currently, no picture format supported by Qt uses the description
- string.
-*/
-
-void QPictureIO::setDescription(const QString &description)
-{
- d->descr = description;
-}
-
-
-/*!
- Returns a string that specifies the picture format of the file \a
- fileName, or null if the file cannot be read or if the format is
- not recognized.
-*/
-
-QByteArray QPictureIO::pictureFormat(const QString &fileName)
-{
- QFile file(fileName);
- QByteArray format;
- if (!file.open(QIODevice::ReadOnly))
- return format;
- format = pictureFormat(&file);
- file.close();
- return format;
-}
-
-/*!
- \overload
-
- Returns a string that specifies the picture format of the picture read
- from IO device \a d, or 0 if the device cannot be read or if the
- format is not recognized.
-
- Make sure that \a d is at the right position in the device (for
- example, at the beginning of the file).
-
- \sa QIODevice::pos()
-*/
-
-QByteArray QPictureIO::pictureFormat(QIODevice *d)
-{
- // if you change this change the documentation for defineIOHandler()
- const int buflen = 14;
-
- char buf[buflen];
- char buf2[buflen];
- qt_init_picture_handlers();
- qt_init_picture_plugins();
- int pos = d->pos(); // save position
- int rdlen = d->read(buf, buflen); // read a few bytes
-
- QByteArray format;
- if (rdlen != buflen)
- return format;
-
- memcpy(buf2, buf, buflen);
-
- for (int n = 0; n < rdlen; n++)
- if (buf[n] == '\0')
- buf[n] = '\001';
- if (rdlen > 0) {
- buf[rdlen - 1] = '\0';
- QString bufStr = QString::fromLatin1(buf);
- if (QPHList *list = pictureHandlers()) {
- for (int i = 0; i < list->size(); ++i) {
- if (list->at(i)->header.indexIn(bufStr) != -1) { // try match with headers
- format = list->at(i)->format;
- break;
- }
- }
- }
- }
- d->seek(pos); // restore position
- return format;
-}
-
-/*!
- Returns a sorted list of picture formats that are supported for
- picture input.
-*/
-QList<QByteArray> QPictureIO::inputFormats()
-{
- QList<QByteArray> result;
-
- qt_init_picture_handlers();
- qt_init_picture_plugins();
-
- if (QPHList *list = pictureHandlers()) {
- for (int i = 0; i < list->size(); ++i) {
- QPictureHandler *p = list->at(i);
- if (p->read_picture && !p->obsolete && !result.contains(p->format))
- result.append(p->format);
- }
- }
- std::sort(result.begin(), result.end());
-
- return result;
-}
-
-/*!
- Returns a sorted list of picture formats that are supported for
- picture output.
-*/
-QList<QByteArray> QPictureIO::outputFormats()
-{
- qt_init_picture_handlers();
- qt_init_picture_plugins();
-
- QList<QByteArray> result;
- if (QPHList *list = pictureHandlers()) {
- for (int i = 0; i < list->size(); ++i) {
- QPictureHandler *p = list->at(i);
- if (p->write_picture && !p->obsolete && !result.contains(p->format))
- result.append(p->format);
- }
- }
- return result;
-}
-
-
-
-/*!
- Reads an picture into memory and returns \c true if the picture was
- successfully read; otherwise returns \c false.
-
- Before reading an picture you must set an IO device or a file name.
- If both an IO device and a file name have been set, the IO device
- will be used.
-
- Setting the picture file format string is optional.
-
- Note that this function does \e not set the \l{format()}{format} used to read the picture. If you need that
- information, use the pictureFormat() static functions.
-
- Example:
-
- \snippet picture/picture.cpp 4
-
- \sa setIODevice(), setFileName(), setFormat(), write(), QPixmap::load()
-*/
-bool QPictureIO::read()
-{
- QFile file;
- QByteArray picture_format;
- QPictureHandler *h;
-
- if (d->iodev) { // read from io device
- // ok, already open
- } else if (!d->fname.isEmpty()) { // read from file
- file.setFileName(d->fname);
- if (!file.open(QIODevice::ReadOnly))
- return false; // cannot open file
- d->iodev = &file;
- } else { // no file name or io device
- return false;
- }
- if (d->frmt.isEmpty()) {
- // Try to guess format
- picture_format = pictureFormat(d->iodev); // get picture format
- if (picture_format.isEmpty()) {
- if (file.isOpen()) { // unknown format
- file.close();
- d->iodev = nullptr;
- }
- return false;
- }
- } else {
- picture_format = d->frmt;
- }
-
- h = get_picture_handler(picture_format);
- if (file.isOpen()) {
-#if !defined(Q_OS_UNIX)
- if (h && h->text_mode) { // reopen in translated mode
- file.close();
- file.open(QIODevice::ReadOnly | QIODevice::Text);
- }
- else
-#endif
- file.seek(0); // position to start
- }
- d->iostat = 1; // assume error
-
- if (h && h->read_picture)
- (*h->read_picture)(this);
-
- if (file.isOpen()) { // picture was read using file
- file.close();
- d->iodev = nullptr;
- }
- return d->iostat == 0; // picture successfully read?
-}
-
-
-/*!
- Writes an picture to an IO device and returns \c true if the picture was
- successfully written; otherwise returns \c false.
-
- Before writing an picture you must set an IO device or a file name.
- If both an IO device and a file name have been set, the IO device
- will be used.
-
- The picture will be written using the specified picture format.
-
- Example:
- \snippet picture/picture.cpp 5
-
- \sa setIODevice(), setFileName(), setFormat(), read(), QPixmap::save()
-*/
-bool QPictureIO::write()
-{
- if (d->frmt.isEmpty())
- return false;
- QPictureHandler *h = get_picture_handler(d->frmt);
- if (!h || !h->write_picture) {
- qWarning("QPictureIO::write: No such picture format handler: %s",
- format());
- return false;
- }
- QFile file;
- if (!d->iodev && !d->fname.isEmpty()) {
- file.setFileName(d->fname);
- bool translate = h->text_mode==QPictureHandler::TranslateInOut;
- QIODevice::OpenMode fmode = translate ? QIODevice::WriteOnly | QIODevice::Text : QIODevice::OpenMode(QIODevice::WriteOnly);
- if (!file.open(fmode)) // couldn't create file
- return false;
- d->iodev = &file;
- }
- d->iostat = 1;
- (*h->write_picture)(this);
- if (file.isOpen()) { // picture was written using file
- file.close();
- d->iodev = nullptr;
- }
- return d->iostat == 0; // picture successfully written?
-}
-#endif //QT_NO_PICTUREIO
-
QT_END_NAMESPACE
#endif // QT_NO_PICTURE
diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h
index 189e57b9a3..34860985ed 100644
--- a/src/gui/image/qpicture.h
+++ b/src/gui/image/qpicture.h
@@ -48,7 +48,6 @@
QT_BEGIN_NAMESPACE
-
#ifndef QT_NO_PICTURE
class QPicturePrivate;
@@ -69,10 +68,10 @@ public:
bool play(QPainter *p);
- bool load(QIODevice *dev, const char *format = nullptr);
- bool load(const QString &fileName, const char *format = nullptr);
- bool save(QIODevice *dev, const char *format = nullptr);
- bool save(const QString &fileName, const char *format = nullptr);
+ bool load(QIODevice *dev);
+ bool load(const QString &fileName);
+ bool save(QIODevice *dev);
+ bool save(const QString &fileName);
QRect boundingRect() const;
void setBoundingRect(const QRect &r);
@@ -88,14 +87,6 @@ public:
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QPicture &p);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QPicture &p);
-#if QT_DEPRECATED_SINCE(5, 10)
- static QT_DEPRECATED const char* pictureFormat(const QString &fileName);
- static QT_DEPRECATED QList<QByteArray> inputFormats();
- static QT_DEPRECATED QList<QByteArray> outputFormats();
- static QT_DEPRECATED QStringList inputFormatList();
- static QT_DEPRECATED QStringList outputFormatList();
-#endif // QT_DEPRECATED_SINCE(5, 10)
-
QPaintEngine *paintEngine() const override;
protected:
@@ -118,67 +109,6 @@ public:
Q_DECLARE_SHARED(QPicture)
-
-#ifndef QT_NO_PICTUREIO
-class QIODevice;
-class QPictureIO;
-typedef void (*picture_io_handler)(QPictureIO *); // picture IO handler
-
-struct QPictureIOData;
-
-class Q_GUI_EXPORT QPictureIO
-{
-public:
- QPictureIO();
- QPictureIO(QIODevice *ioDevice, const char *format);
- QPictureIO(const QString &fileName, const char *format);
- ~QPictureIO();
-
- const QPicture &picture() const;
- int status() const;
- const char *format() const;
- QIODevice *ioDevice() const;
- QString fileName() const;
- int quality() const;
- QString description() const;
- const char *parameters() const;
- float gamma() const;
-
- void setPicture(const QPicture &);
- void setStatus(int);
- void setFormat(const char *);
- void setIODevice(QIODevice *);
- void setFileName(const QString &);
- void setQuality(int);
- void setDescription(const QString &);
- void setParameters(const char *);
- void setGamma(float);
-
- bool read();
- bool write();
-
- static QByteArray pictureFormat(const QString &fileName);
- static QByteArray pictureFormat(QIODevice *);
- static QList<QByteArray> inputFormats();
- static QList<QByteArray> outputFormats();
-
- static void defineIOHandler(const char *format,
- const char *header,
- const char *flags,
- picture_io_handler read_picture,
- picture_io_handler write_picture);
-
-private:
- Q_DISABLE_COPY(QPictureIO)
-
- void init();
-
- QPictureIOData *d;
-};
-
-#endif //QT_NO_PICTUREIO
-
-
/*****************************************************************************
QPicture stream functions
*****************************************************************************/
diff --git a/src/gui/image/qpictureformatplugin.cpp b/src/gui/image/qpictureformatplugin.cpp
deleted file mode 100644
index ef57ad720f..0000000000
--- a/src/gui/image/qpictureformatplugin.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpictureformatplugin.h"
-#if !defined(QT_NO_PICTURE)
-#include "qpicture.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \obsolete
-
- \class QPictureFormatPlugin
- \brief The QPictureFormatPlugin class provides an abstract base
- for custom picture format plugins.
-
- \ingroup plugins
- \inmodule QtGui
-
- The picture format plugin is a simple plugin interface that makes
- it easy to create custom picture formats that can be used
- transparently by applications.
-
- Writing an picture format plugin is achieved by subclassing this
- base class, reimplementing the pure virtual functions
- loadPicture(), savePicture(), and installIOHandler(), and
- exporting the class with the Q_PLUGIN_METADATA() macro.
-
- The json file containing the metadata should contain one entry
- with the list of picture formats supported by the plugin:
-
- \code
- { "Keys": [ "mypictureformat" ] }
- \endcode
-
- \sa {How to Create Qt Plugins}
-*/
-
-/*!
- \fn bool QPictureFormatPlugin::installIOHandler(const QString &format)
-
- Installs a QPictureIO picture I/O handler for the picture format \a
- format. Returns \c true on success.
-*/
-
-
-/*!
- Constructs an picture format plugin with the given \a parent.
- This is invoked automatically by the moc generated code that exports the plugin.
-*/
-QPictureFormatPlugin::QPictureFormatPlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-/*!
- Destroys the picture format plugin.
-
- You never have to call this explicitly. Qt destroys a plugin
- automatically when it is no longer used.
-*/
-QPictureFormatPlugin::~QPictureFormatPlugin()
-{
-}
-
-
-/*!
- Loads the picture stored in the file called \a fileName, with the
- given \a format, into *\a picture. Returns \c true on success;
- otherwise returns \c false.
-
- \sa savePicture()
-*/
-bool QPictureFormatPlugin::loadPicture(const QString &format, const QString &fileName, QPicture *picture)
-{
- Q_UNUSED(format)
- Q_UNUSED(fileName)
- Q_UNUSED(picture)
- return false;
-}
-
-/*!
- Saves the given \a picture into the file called \a fileName,
- using the specified \a format. Returns \c true on success; otherwise
- returns \c false.
-
- \sa loadPicture()
-*/
-bool QPictureFormatPlugin::savePicture(const QString &format, const QString &fileName, const QPicture &picture)
-{
- Q_UNUSED(format)
- Q_UNUSED(fileName)
- Q_UNUSED(picture)
- return false;
-}
-
-#endif // QT_NO_PICTURE
-
-QT_END_NAMESPACE
diff --git a/src/gui/image/qpictureformatplugin.h b/src/gui/image/qpictureformatplugin.h
deleted file mode 100644
index 3f59c04d79..0000000000
--- a/src/gui/image/qpictureformatplugin.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPICTUREFORMATPLUGIN_H
-#define QPICTUREFORMATPLUGIN_H
-
-#include <QtGui/qtguiglobal.h>
-#include <QtCore/qplugin.h>
-#include <QtCore/qfactoryinterface.h>
-
-QT_BEGIN_NAMESPACE
-
-
-#if !defined(QT_NO_PICTURE)
-
-class QPicture;
-class QImage;
-class QString;
-class QStringList;
-
-#define QPictureFormatInterface_iid "org.qt-project.Qt.QPictureFormatInterface"
-
-class Q_GUI_EXPORT QPictureFormatPlugin : public QObject
-{
- Q_OBJECT
-public:
- explicit QPictureFormatPlugin(QObject *parent = nullptr);
- ~QPictureFormatPlugin();
-
- virtual bool loadPicture(const QString &format, const QString &filename, QPicture *pic);
- virtual bool savePicture(const QString &format, const QString &filename, const QPicture &pic);
- virtual bool installIOHandler(const QString &format) = 0;
-
-};
-
-#endif // QT_NO_PICTURE
-
-QT_END_NAMESPACE
-
-#endif // QPICTUREFORMATPLUGIN_H
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
index 8aad77b991..be6cd0c5fc 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/gui/image/qpixmap_win.cpp
@@ -121,7 +121,7 @@ static inline void copyImageDataCreateAlpha(const uchar *data, QImage *target)
const uint mask = target->format() == QImage::Format_RGB32 ? 0xff000000 : 0;
const int height = target->height();
const int width = target->width();
- const int bytesPerLine = width * int(sizeof(QRgb));
+ const qsizetype bytesPerLine = width * sizeof(QRgb);
for (int y = 0; y < height; ++y) {
QRgb *dest = reinterpret_cast<QRgb *>(target->scanLine(y));
const QRgb *src = reinterpret_cast<const QRgb *>(data + y * bytesPerLine);
diff --git a/src/gui/image/qplatformpixmap.cpp b/src/gui/image/qplatformpixmap.cpp
index 493f55514e..ea4243ba07 100644
--- a/src/gui/image/qplatformpixmap.cpp
+++ b/src/gui/image/qplatformpixmap.cpp
@@ -183,7 +183,7 @@ QBitmap QPlatformPixmap::mask() const
mask.setColor(0, QColor(Qt::color0).rgba());
mask.setColor(1, QColor(Qt::color1).rgba());
- const int bpl = mask.bytesPerLine();
+ const qsizetype bpl = mask.bytesPerLine();
for (int y = 0; y < h; ++y) {
const QRgb *src = reinterpret_cast<const QRgb*>(image.scanLine(y));
@@ -216,7 +216,7 @@ void QPlatformPixmap::setMask(const QBitmap &mask)
for (int y = 0; y < h; ++y) {
const uchar *mscan = imageMask.scanLine(y);
uchar *tscan = image.scanLine(y);
- int bytesPerLine = image.bytesPerLine();
+ qsizetype bytesPerLine = image.bytesPerLine();
for (int i = 0; i < bytesPerLine; ++i)
tscan[i] &= mscan[i];
}
diff --git a/src/gui/image/qplatformpixmap.h b/src/gui/image/qplatformpixmap.h
index 7635ac2949..9c7f5e5edf 100644
--- a/src/gui/image/qplatformpixmap.h
+++ b/src/gui/image/qplatformpixmap.h
@@ -163,7 +163,7 @@ private:
# define QT_XFORM_TYPE_MSBFIRST 0
# define QT_XFORM_TYPE_LSBFIRST 1
-Q_GUI_EXPORT bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, int, int, int, const uchar*, int, int, int);
+Q_GUI_EXPORT bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, qsizetype, int, int, const uchar*, qsizetype, int, int);
QT_END_NAMESPACE
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index 8435e5a0fe..e6a3604ad4 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -455,7 +455,7 @@ static void read_image_scaled(QImage *outImage, png_structp png_ptr, png_infop i
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr);
png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, &unit_type);
uchar *data = outImage->bits();
- int bpl = outImage->bytesPerLine();
+ qsizetype bpl = outImage->bytesPerLine();
if (scaledSize.isEmpty() || !width || !height)
return;
@@ -709,7 +709,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage)
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr);
png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, &unit_type);
uchar *data = outImage->bits();
- int bpl = outImage->bytesPerLine();
+ qsizetype bpl = outImage->bytesPerLine();
amp.row_pointers = new png_bytep[height];
for (uint y = 0; y < height; y++)
diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp
index 13ee2eadd2..195e58d283 100644
--- a/src/gui/image/qppmhandler.cpp
+++ b/src/gui/image/qppmhandler.cpp
@@ -135,7 +135,7 @@ static inline QRgb scale_pbm_color(quint16 mx, quint16 rv, quint16 gv, quint16 b
static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, QImage *outImage)
{
int nbits, y;
- int pbm_bpl;
+ qsizetype pbm_bpl;
bool raw;
QImage::Format format;
@@ -166,7 +166,7 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
return false;
}
- pbm_bpl = (nbits*w+7)/8; // bytes per scanline in PBM
+ pbm_bpl = (qsizetype(w) * nbits + 7) / 8; // bytes per scanline in PBM
if (raw) { // read raw data
if (nbits == 32) { // type 6
@@ -225,14 +225,14 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
if (device->read((char *)p, pbm_bpl) != pbm_bpl)
return false;
if (nbits == 8 && mcc < 255) {
- for (int i = 0; i < pbm_bpl; i++)
+ for (qsizetype i = 0; i < pbm_bpl; i++)
p[i] = (p[i] * 255) / mcc;
}
}
}
} else { // read ascii data
uchar *p;
- int n;
+ qsizetype n;
char buf;
for (y = 0; (y < h) && (device->peek(&buf, 1) == 1); y++) {
p = outImage->scanLine(y);
@@ -367,7 +367,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
str.append("255\n");
if (out->write(str, str.length()) != str.length())
return false;
- uint bpl = w * (gray ? 1 : 3);
+ qsizetype bpl = qsizetype(w) * (gray ? 1 : 3);
uchar *buf = new uchar[bpl];
if (image.format() == QImage::Format_Indexed8) {
QVector<QRgb> color = image.colorTable();
@@ -388,7 +388,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
*p++ = qBlue(rgb);
}
}
- if (bpl != (uint)out->write((char*)buf, bpl))
+ if (bpl != (qsizetype)out->write((char*)buf, bpl))
return false;
}
} else {
@@ -407,7 +407,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
*p++ = color;
}
}
- if (bpl != (uint)out->write((char*)buf, bpl))
+ if (bpl != (qsizetype)out->write((char*)buf, bpl))
return false;
}
}
@@ -420,7 +420,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
str.append("255\n");
if (out->write(str, str.length()) != str.length())
return false;
- uint bpl = w * 3;
+ qsizetype bpl = qsizetype(w) * 3;
uchar *buf = new uchar[bpl];
for (uint y=0; y<h; y++) {
const QRgb *b = reinterpret_cast<const QRgb *>(image.constScanLine(y));
@@ -432,7 +432,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
*p++ = qGreen(rgb);
*p++ = qBlue(rgb);
}
- if (bpl != (uint)out->write((char*)buf, bpl))
+ if (bpl != (qsizetype)out->write((char*)buf, bpl))
return false;
}
delete [] buf;