Get rid of some obsolete functions in QImage / QPixmap / QPixmapData.
Change-Id: I0d2412c9196475b926a17de9fcc3281f6625fae0 Reviewed-on: http://codereview.qt.nokia.com/1733 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com> Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
This commit is contained in:
parent
a81093b915
commit
bc0a0281d5
@ -1,108 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
** All rights reserved.
|
|
||||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
||||||
**
|
|
||||||
** This file is part of the documentation of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:BSD$
|
|
||||||
** You may use this file under the terms of the BSD license as follows:
|
|
||||||
**
|
|
||||||
** "Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions are
|
|
||||||
** met:
|
|
||||||
** * Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** * Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in
|
|
||||||
** the documentation and/or other materials provided with the
|
|
||||||
** distribution.
|
|
||||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
|
||||||
** the names of its contributors may be used to endorse or promote
|
|
||||||
** products derived from this software without specific prior written
|
|
||||||
** permission.
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <qlabel.h>
|
|
||||||
#include <qpixmap.h>
|
|
||||||
#include <qprinter.h>
|
|
||||||
#include <qpainter.h>
|
|
||||||
#include <qfile.h>
|
|
||||||
#include <qdir.h>
|
|
||||||
#include <qfileinfo.h>
|
|
||||||
#include <QtGui>
|
|
||||||
#include <QtCore>
|
|
||||||
|
|
||||||
class MyClass : public QWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MyClass(QWidget *parent = 0) : QWidget(parent) { }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent *e)
|
|
||||||
{
|
|
||||||
/*QRadialGradient rg(50, 50, 50, 50, 50);
|
|
||||||
rg.setColorAt(0, QColor::fromRgbF(1, 0, 0, 1));
|
|
||||||
rg.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
|
|
||||||
QPainter pmp(&pm);
|
|
||||||
pmp.fillRect(0, 0, 100, 100, rg);
|
|
||||||
pmp.end();*/
|
|
||||||
|
|
||||||
createImage();
|
|
||||||
|
|
||||||
QPainter p(this);
|
|
||||||
p.fillRect(rect(), Qt::white);
|
|
||||||
|
|
||||||
p.drawPixmap(0, 0, pixmap);
|
|
||||||
|
|
||||||
p.drawPixmap(100, 0, channelImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
void createImage()
|
|
||||||
{
|
|
||||||
//! [0]
|
|
||||||
pixmap = QPixmap(100, 100);
|
|
||||||
pixmap.fill(Qt::transparent);
|
|
||||||
|
|
||||||
QRadialGradient gradient(50, 50, 50, 50, 50);
|
|
||||||
gradient.setColorAt(0, QColor::fromRgbF(1, 0, 0, 1));
|
|
||||||
gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
|
|
||||||
QPainter painter(&pixmap);
|
|
||||||
painter.fillRect(0, 0, 100, 100, gradient);
|
|
||||||
|
|
||||||
channelImage = pixmap.alphaChannel();
|
|
||||||
update();
|
|
||||||
//! [0]
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap channelImage, pixmap;
|
|
||||||
QSize sizeHint() const { return QSize(500, 500); }
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
QApplication app(argc, argv);
|
|
||||||
|
|
||||||
MyClass cl;
|
|
||||||
cl.show();
|
|
||||||
QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
|
|
||||||
|
|
||||||
int ret = app.exec();
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1354,10 +1354,6 @@ int QImage::depth() const
|
|||||||
|
|
||||||
\sa setColorCount()
|
\sa setColorCount()
|
||||||
*/
|
*/
|
||||||
int QImage::numColors() const
|
|
||||||
{
|
|
||||||
return d ? d->colortable.size() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.6
|
\since 4.6
|
||||||
@ -1425,10 +1421,6 @@ QVector<QRgb> QImage::colorTable() const
|
|||||||
|
|
||||||
\sa byteCount()
|
\sa byteCount()
|
||||||
*/
|
*/
|
||||||
int QImage::numBytes() const
|
|
||||||
{
|
|
||||||
return d ? d->nbytes : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.6
|
\since 4.6
|
||||||
@ -1862,10 +1854,6 @@ void QImage::invertPixels(InvertMode mode)
|
|||||||
\sa setColorCount()
|
\sa setColorCount()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void QImage::setNumColors(int numColors)
|
|
||||||
{
|
|
||||||
setColorCount(numColors);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.6
|
\since 4.6
|
||||||
@ -5084,15 +5072,6 @@ void QImage::setText(const QString &key, const QString &value)
|
|||||||
The language the text is recorded in is no longer relevant since
|
The language the text is recorded in is no longer relevant since
|
||||||
the text is always set using QString and UTF-8 representation.
|
the text is always set using QString and UTF-8 representation.
|
||||||
*/
|
*/
|
||||||
QString QImage::text(const char* key, const char* lang) const
|
|
||||||
{
|
|
||||||
if (!d)
|
|
||||||
return QString();
|
|
||||||
QString k = QString::fromAscii(key);
|
|
||||||
if (lang && *lang)
|
|
||||||
k += QLatin1Char('/') + QString::fromAscii(lang);
|
|
||||||
return d->text.value(k);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QString QImage::text(const QImageTextKeyLang& keywordAndLanguage) const
|
\fn QString QImage::text(const QImageTextKeyLang& keywordAndLanguage) const
|
||||||
@ -5106,15 +5085,6 @@ QString QImage::text(const char* key, const char* lang) const
|
|||||||
The language the text is recorded in is no longer relevant since
|
The language the text is recorded in is no longer relevant since
|
||||||
the text is always set using QString and UTF-8 representation.
|
the text is always set using QString and UTF-8 representation.
|
||||||
*/
|
*/
|
||||||
QString QImage::text(const QImageTextKeyLang& kl) const
|
|
||||||
{
|
|
||||||
if (!d)
|
|
||||||
return QString();
|
|
||||||
QString k = QString::fromAscii(kl.key);
|
|
||||||
if (!kl.lang.isEmpty())
|
|
||||||
k += QLatin1Char('/') + QString::fromAscii(kl.lang);
|
|
||||||
return d->text.value(k);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\obsolete
|
\obsolete
|
||||||
@ -5126,20 +5096,6 @@ QString QImage::text(const QImageTextKeyLang& kl) const
|
|||||||
The language the text is recorded in is no longer relevant since
|
The language the text is recorded in is no longer relevant since
|
||||||
the text is always set using QString and UTF-8 representation.
|
the text is always set using QString and UTF-8 representation.
|
||||||
*/
|
*/
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\obsolete
|
\obsolete
|
||||||
@ -5152,24 +5108,6 @@ QStringList QImage::textLanguages() const
|
|||||||
The language the text is recorded in is no longer relevant since
|
The language the text is recorded in is no longer relevant since
|
||||||
the text is always set using QString and UTF-8 representation.
|
the text is always set using QString and UTF-8 representation.
|
||||||
*/
|
*/
|
||||||
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;
|
|
||||||
tkl.key = keys.at(i).left(index).toAscii();
|
|
||||||
tkl.lang = keys.at(i).mid(index+1).toAscii();
|
|
||||||
imageTextKeys += tkl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return imageTextKeys;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void QImage::setText(const char* key, const char* language, const QString& text)
|
\fn void QImage::setText(const char* key, const char* language, const QString& text)
|
||||||
@ -5194,21 +5132,6 @@ QList<QImageTextKeyLang> QImage::textList() const
|
|||||||
\l{http://www.rfc-editor.org/rfc/rfc1766.txt}{RFC 1766}) or 0.
|
\l{http://www.rfc-editor.org/rfc/rfc1766.txt}{RFC 1766}) or 0.
|
||||||
\endomit
|
\endomit
|
||||||
*/
|
*/
|
||||||
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::fromAscii(key);
|
|
||||||
if (lang && *lang)
|
|
||||||
k += QLatin1Char('/') + QString::fromAscii(lang);
|
|
||||||
d->text.insert(k, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // QT_NO_IMAGE_TEXT
|
#endif // QT_NO_IMAGE_TEXT
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ template <class T> class QVector;
|
|||||||
struct QImageData;
|
struct QImageData;
|
||||||
class QImageDataMisc; // internal
|
class QImageDataMisc; // internal
|
||||||
#ifndef QT_NO_IMAGE_TEXT
|
#ifndef QT_NO_IMAGE_TEXT
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 0)
|
||||||
class Q_GUI_EXPORT QImageTextKeyLang {
|
class Q_GUI_EXPORT QImageTextKeyLang {
|
||||||
public:
|
public:
|
||||||
QImageTextKeyLang(const char* k, const char* l) : key(k), lang(l) { }
|
QImageTextKeyLang(const char* k, const char* l) : key(k), lang(l) { }
|
||||||
@ -81,6 +82,7 @@ public:
|
|||||||
inline bool operator!= (const QImageTextKeyLang &other) const
|
inline bool operator!= (const QImageTextKeyLang &other) const
|
||||||
{ return !operator==(other); }
|
{ return !operator==(other); }
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
#endif //QT_NO_IMAGE_TEXT
|
#endif //QT_NO_IMAGE_TEXT
|
||||||
|
|
||||||
|
|
||||||
@ -168,17 +170,11 @@ public:
|
|||||||
QRect rect() const;
|
QRect rect() const;
|
||||||
|
|
||||||
int depth() const;
|
int depth() const;
|
||||||
#ifdef QT_DEPRECATED
|
|
||||||
QT_DEPRECATED int numColors() const;
|
|
||||||
#endif
|
|
||||||
int colorCount() const;
|
int colorCount() const;
|
||||||
int bitPlaneCount() const;
|
int bitPlaneCount() const;
|
||||||
|
|
||||||
QRgb color(int i) const;
|
QRgb color(int i) const;
|
||||||
void setColor(int i, QRgb c);
|
void setColor(int i, QRgb c);
|
||||||
#ifdef QT_DEPRECATED
|
|
||||||
QT_DEPRECATED void setNumColors(int);
|
|
||||||
#endif
|
|
||||||
void setColorCount(int);
|
void setColorCount(int);
|
||||||
|
|
||||||
bool allGray() const;
|
bool allGray() const;
|
||||||
@ -187,9 +183,7 @@ public:
|
|||||||
uchar *bits();
|
uchar *bits();
|
||||||
const uchar *bits() const;
|
const uchar *bits() const;
|
||||||
const uchar *constBits() const;
|
const uchar *constBits() const;
|
||||||
#ifdef QT_DEPRECATED
|
|
||||||
QT_DEPRECATED int numBytes() const;
|
|
||||||
#endif
|
|
||||||
int byteCount() const;
|
int byteCount() const;
|
||||||
|
|
||||||
uchar *scanLine(int);
|
uchar *scanLine(int);
|
||||||
@ -272,12 +266,19 @@ public:
|
|||||||
QString text(const QString &key = QString()) const;
|
QString text(const QString &key = QString()) const;
|
||||||
void setText(const QString &key, const QString &value);
|
void setText(const QString &key, const QString &value);
|
||||||
|
|
||||||
// The following functions are obsolete as of 4.1
|
#if QT_DEPRECATED_SINCE(5, 0)
|
||||||
QString text(const char* key, const char* lang=0) const;
|
inline QString text(const char* key, const char* lang=0) const;
|
||||||
QList<QImageTextKeyLang> textList() const;
|
inline QList<QImageTextKeyLang> textList() const;
|
||||||
QStringList textLanguages() const;
|
inline QStringList textLanguages() const;
|
||||||
QString text(const QImageTextKeyLang&) const;
|
inline QString text(const QImageTextKeyLang&) const;
|
||||||
void setText(const char* key, const char* lang, const QString&);
|
inline void setText(const char* key, const char* lang, const QString&);
|
||||||
|
#endif
|
||||||
|
#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
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -308,6 +309,94 @@ Q_GUI_EXPORT_INLINE int QImage::pixelIndex(const QPoint &pt) const { return pixe
|
|||||||
Q_GUI_EXPORT_INLINE QRgb QImage::pixel(const QPoint &pt) const { return pixel(pt.x(), pt.y()); }
|
Q_GUI_EXPORT_INLINE QRgb QImage::pixel(const QPoint &pt) const { return pixel(pt.x(), pt.y()); }
|
||||||
Q_GUI_EXPORT_INLINE void QImage::setPixel(const QPoint &pt, uint index_or_rgb) { setPixel(pt.x(), pt.y(), index_or_rgb); }
|
Q_GUI_EXPORT_INLINE void QImage::setPixel(const QPoint &pt, uint index_or_rgb) { setPixel(pt.x(), pt.y(), index_or_rgb); }
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 0)
|
||||||
|
#ifndef QT_NO_IMAGE_TEXT
|
||||||
|
inline QString QImage::text(const char* key, const char* lang) const
|
||||||
|
{
|
||||||
|
if (!d)
|
||||||
|
return QString();
|
||||||
|
QString k = QString::fromAscii(key);
|
||||||
|
if (lang && *lang)
|
||||||
|
k += QLatin1Char('/') + QString::fromAscii(lang);
|
||||||
|
return d->text.value(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;
|
||||||
|
tkl.key = keys.at(i).left(index).toAscii();
|
||||||
|
tkl.lang = keys.at(i).mid(index+1).toAscii();
|
||||||
|
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&) const
|
||||||
|
{
|
||||||
|
if (!d)
|
||||||
|
return QString();
|
||||||
|
QString k = QString::fromAscii(kl.key);
|
||||||
|
if (!kl.lang.isEmpty())
|
||||||
|
k += QLatin1Char('/') + QString::fromAscii(kl.lang);
|
||||||
|
return d->text.value(k);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void QImage::setText(const char* key, const char* lang, const QString&)
|
||||||
|
{
|
||||||
|
if (!d)
|
||||||
|
return;
|
||||||
|
detach();
|
||||||
|
|
||||||
|
// In case detach() ran out of memory
|
||||||
|
if (!d)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString k = QString::fromAscii(key);
|
||||||
|
if (lang && *lang)
|
||||||
|
k += QLatin1Char('/') + QString::fromAscii(lang);
|
||||||
|
d->text.insert(k, s);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
inline int QImage::numColors() const
|
||||||
|
{
|
||||||
|
return d ? d->colortable.size() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void QImage::setNumColors(int)
|
||||||
|
{
|
||||||
|
setColorCount(numColors);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int QImage::numBytes() const
|
||||||
|
{
|
||||||
|
return d ? d->nbytes : 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// QImage stream functions
|
// QImage stream functions
|
||||||
|
|
||||||
#if !defined(QT_NO_DATASTREAM)
|
#if !defined(QT_NO_DATASTREAM)
|
||||||
|
@ -63,36 +63,15 @@
|
|||||||
#include "qthread.h"
|
#include "qthread.h"
|
||||||
#include "qdebug.h"
|
#include "qdebug.h"
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
# include "private/qt_mac_p.h"
|
|
||||||
# include "private/qpixmap_mac_p.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_WS_QPA
|
#ifdef Q_WS_QPA
|
||||||
# include "qplatformintegration_qpa.h"
|
# include "qplatformintegration_qpa.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_WS_X11)
|
|
||||||
# include "qx11info_x11.h"
|
|
||||||
# include <private/qt_x11_p.h>
|
|
||||||
# include <private/qpixmap_x11_p.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Q_OS_SYMBIAN)
|
|
||||||
# include <private/qt_s60_p.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "qpixmap_raster_p.h"
|
#include "qpixmap_raster_p.h"
|
||||||
#include "private/qhexstring_p.h"
|
#include "private/qhexstring_p.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
// ### Qt 5: remove
|
|
||||||
Q_GUI_EXPORT qint64 qt_pixmap_id(const QPixmap &pixmap)
|
|
||||||
{
|
|
||||||
return pixmap.cacheKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool qt_pixmap_thread_test()
|
static bool qt_pixmap_thread_test()
|
||||||
{
|
{
|
||||||
if (!QCoreApplication::instance()) {
|
if (!QCoreApplication::instance()) {
|
||||||
@ -114,11 +93,6 @@ static bool qt_pixmap_thread_test()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QPixmap::init(int w, int h, Type type)
|
|
||||||
{
|
|
||||||
init(w, h, int(type));
|
|
||||||
}
|
|
||||||
|
|
||||||
void QPixmap::init(int w, int h, int type)
|
void QPixmap::init(int w, int h, int type)
|
||||||
{
|
{
|
||||||
if ((w > 0 && h > 0) || type == QPixmapData::BitmapType)
|
if ((w > 0 && h > 0) || type == QPixmapData::BitmapType)
|
||||||
@ -198,17 +172,6 @@ QPixmap::QPixmap(const QSize &size)
|
|||||||
init(size.width(), size.height(), QPixmapData::PixmapType);
|
init(size.width(), size.height(), QPixmapData::PixmapType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\internal
|
|
||||||
*/
|
|
||||||
QPixmap::QPixmap(const QSize &s, Type type)
|
|
||||||
{
|
|
||||||
if (!qt_pixmap_thread_test())
|
|
||||||
init(0, 0, type);
|
|
||||||
else
|
|
||||||
init(s.width(), s.height(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
@ -698,7 +661,44 @@ void QPixmap::setMask(const QBitmap &mask)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
detach();
|
detach();
|
||||||
data->setMask(mask);
|
|
||||||
|
QImage image = data->toImage();
|
||||||
|
if (mask.size().isEmpty()) {
|
||||||
|
if (image.depth() != 1) { // hw: ????
|
||||||
|
image = image.convertToFormat(QImage::Format_RGB32);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const int w = image.width();
|
||||||
|
const int h = image.height();
|
||||||
|
|
||||||
|
switch (image.depth()) {
|
||||||
|
case 1: {
|
||||||
|
const QImage imageMask = mask.toImage().convertToFormat(image.format());
|
||||||
|
for (int y = 0; y < h; ++y) {
|
||||||
|
const uchar *mscan = imageMask.scanLine(y);
|
||||||
|
uchar *tscan = image.scanLine(y);
|
||||||
|
int bytesPerLine = image.bytesPerLine();
|
||||||
|
for (int i = 0; i < bytesPerLine; ++i)
|
||||||
|
tscan[i] &= mscan[i];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
const QImage imageMask = mask.toImage().convertToFormat(QImage::Format_MonoLSB);
|
||||||
|
image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
||||||
|
for (int y = 0; y < h; ++y) {
|
||||||
|
const uchar *mscan = imageMask.scanLine(y);
|
||||||
|
QRgb *tscan = (QRgb *)image.scanLine(y);
|
||||||
|
for (int x = 0; x < w; ++x) {
|
||||||
|
if (!(mscan[x>>3] & (1 << (x&7))))
|
||||||
|
tscan[x] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data->fromImage(image, Qt::AutoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_IMAGE_HEURISTIC_MASK
|
#ifndef QT_NO_IMAGE_HEURISTIC_MASK
|
||||||
@ -745,19 +745,6 @@ QBitmap QPixmap::createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode)
|
|||||||
return QBitmap::fromImage(image.createMaskFromColor(maskColor.rgba(), mode));
|
return QBitmap::fromImage(image.createMaskFromColor(maskColor.rgba(), mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \overload
|
|
||||||
|
|
||||||
Creates and returns a mask for this pixmap based on the given \a
|
|
||||||
maskColor. Same as calling createMaskFromColor(maskColor,
|
|
||||||
Qt::MaskInColor)
|
|
||||||
|
|
||||||
\sa createHeuristicMask(), QImage::createMaskFromColor()
|
|
||||||
*/
|
|
||||||
QBitmap QPixmap::createMaskFromColor(const QColor &maskColor) const
|
|
||||||
{
|
|
||||||
return createMaskFromColor(maskColor, Qt::MaskInColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Loads a pixmap from the file with the given \a fileName. Returns
|
Loads a pixmap from the file with the given \a fileName. Returns
|
||||||
true if the pixmap was successfully loaded; otherwise returns
|
true if the pixmap was successfully loaded; otherwise returns
|
||||||
@ -1133,38 +1120,6 @@ QPixmap QPixmap::grabWidget(QPaintDevice *, const QRect &)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if defined(Q_WS_X11) || defined(Q_WS_QWS)
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Returns the pixmap's handle to the device context.
|
|
||||||
|
|
||||||
Note that, since QPixmap make use of \l {Implicit Data
|
|
||||||
Sharing}{implicit data sharing}, the detach() function must be
|
|
||||||
called explicitly to ensure that only \e this pixmap's data is
|
|
||||||
modified if the pixmap data is shared.
|
|
||||||
|
|
||||||
\warning This function is X11 specific; using it is non-portable.
|
|
||||||
|
|
||||||
\warning Since 4.8, pixmaps do not have an X11 handle unless
|
|
||||||
created with \l {QPixmap::}{fromX11Pixmap()}, or if the native
|
|
||||||
graphics system is explicitly enabled.
|
|
||||||
|
|
||||||
\sa detach()
|
|
||||||
*/
|
|
||||||
|
|
||||||
Qt::HANDLE QPixmap::handle() const
|
|
||||||
{
|
|
||||||
#if defined(Q_WS_X11)
|
|
||||||
const QPixmapData *pd = pixmapData();
|
|
||||||
if (pd && pd->classId() == QPixmapData::X11Class)
|
|
||||||
return static_cast<const QX11PixmapData*>(pd)->handle();
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
QPixmap stream functions
|
QPixmap stream functions
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -1638,23 +1593,7 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode)
|
|||||||
*/
|
*/
|
||||||
bool QPixmap::hasAlpha() const
|
bool QPixmap::hasAlpha() const
|
||||||
{
|
{
|
||||||
#if defined(Q_WS_X11)
|
|
||||||
if (data && data->hasAlphaChannel())
|
|
||||||
return true;
|
|
||||||
QPixmapData *pd = pixmapData();
|
|
||||||
if (pd && pd->classId() == QPixmapData::X11Class) {
|
|
||||||
QX11PixmapData *x11Data = static_cast<QX11PixmapData*>(pd);
|
|
||||||
#ifndef QT_NO_XRENDER
|
|
||||||
if (x11Data->picture && x11Data->d == 32)
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
if (x11Data->d == 1 || x11Data->x11_mask)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
return data && data->hasAlphaChannel();
|
return data && data->hasAlphaChannel();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1676,78 +1615,6 @@ int QPixmap::metric(PaintDeviceMetric metric) const
|
|||||||
return data ? data->metric(metric) : 0;
|
return data ? data->metric(metric) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn void QPixmap::setAlphaChannel(const QPixmap &alphaChannel)
|
|
||||||
\obsolete
|
|
||||||
|
|
||||||
Sets the alpha channel of this pixmap to the given \a alphaChannel
|
|
||||||
by converting the \a alphaChannel into 32 bit and using the
|
|
||||||
intensity of the RGB pixel values.
|
|
||||||
|
|
||||||
The effect of this function is undefined when the pixmap is being
|
|
||||||
painted on.
|
|
||||||
|
|
||||||
\warning This is potentially an expensive operation. Most usecases
|
|
||||||
for this function are covered by QPainter and compositionModes
|
|
||||||
which will normally execute faster.
|
|
||||||
|
|
||||||
\sa alphaChannel(), {QPixmap#Pixmap Transformations}{Pixmap
|
|
||||||
Transformations}
|
|
||||||
*/
|
|
||||||
void QPixmap::setAlphaChannel(const QPixmap &alphaChannel)
|
|
||||||
{
|
|
||||||
if (alphaChannel.isNull())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (paintingActive()) {
|
|
||||||
qWarning("QPixmap::setAlphaChannel: "
|
|
||||||
"Cannot set alpha channel while pixmap is being painted on");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (width() != alphaChannel.width() && height() != alphaChannel.height()) {
|
|
||||||
qWarning("QPixmap::setAlphaChannel: "
|
|
||||||
"The pixmap and the alpha channel pixmap must have the same size");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
detach();
|
|
||||||
data->setAlphaChannel(alphaChannel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\obsolete
|
|
||||||
|
|
||||||
Returns the alpha channel of the pixmap as a new grayscale QPixmap in which
|
|
||||||
each pixel's red, green, and blue values are given the alpha value of the
|
|
||||||
original pixmap. The color depth of the returned pixmap is the system depth
|
|
||||||
on X11 and 8-bit on Windows and Mac OS X.
|
|
||||||
|
|
||||||
You can use this function while debugging
|
|
||||||
to get a visible image of the alpha channel. If the pixmap doesn't have an
|
|
||||||
alpha channel, i.e., the alpha channel's value for all pixels equals
|
|
||||||
0xff), a null pixmap is returned. You can check this with the \c isNull()
|
|
||||||
function.
|
|
||||||
|
|
||||||
We show an example:
|
|
||||||
|
|
||||||
\snippet doc/src/snippets/alphachannel.cpp 0
|
|
||||||
|
|
||||||
\image alphachannelimage.png The pixmap and channelImage QPixmaps
|
|
||||||
|
|
||||||
\warning This is an expensive operation. The alpha channel of the
|
|
||||||
pixmap is extracted dynamically from the pixeldata. Most usecases of this
|
|
||||||
function are covered by QPainter and compositionModes which will normally
|
|
||||||
execute faster.
|
|
||||||
|
|
||||||
\sa setAlphaChannel(), {QPixmap#Pixmap Information}{Pixmap
|
|
||||||
Information}
|
|
||||||
*/
|
|
||||||
QPixmap QPixmap::alphaChannel() const
|
|
||||||
{
|
|
||||||
return data ? data->alphaChannel() : QPixmap();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
@ -1768,7 +1635,36 @@ QPaintEngine *QPixmap::paintEngine() const
|
|||||||
*/
|
*/
|
||||||
QBitmap QPixmap::mask() const
|
QBitmap QPixmap::mask() const
|
||||||
{
|
{
|
||||||
return data ? data->mask() : QBitmap();
|
if (!data || !hasAlphaChannel())
|
||||||
|
return QBitmap();
|
||||||
|
|
||||||
|
const QImage img = toImage();
|
||||||
|
const QImage image = (img.depth() < 32 ? img.convertToFormat(QImage::Format_ARGB32_Premultiplied) : img);
|
||||||
|
const int w = image.width();
|
||||||
|
const int h = image.height();
|
||||||
|
|
||||||
|
QImage mask(w, h, QImage::Format_MonoLSB);
|
||||||
|
if (mask.isNull()) // allocation failed
|
||||||
|
return QBitmap();
|
||||||
|
|
||||||
|
mask.setColorCount(2);
|
||||||
|
mask.setColor(0, QColor(Qt::color0).rgba());
|
||||||
|
mask.setColor(1, QColor(Qt::color1).rgba());
|
||||||
|
|
||||||
|
const int bpl = mask.bytesPerLine();
|
||||||
|
|
||||||
|
for (int y = 0; y < h; ++y) {
|
||||||
|
const QRgb *src = reinterpret_cast<const QRgb*>(image.scanLine(y));
|
||||||
|
uchar *dest = mask.scanLine(y);
|
||||||
|
memset(dest, 0, bpl);
|
||||||
|
for (int x = 0; x < w; ++x) {
|
||||||
|
if (qAlpha(*src) > 0)
|
||||||
|
dest[x >> 3] |= (1 << (x & 7));
|
||||||
|
++src;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QBitmap::fromImage(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1783,21 +1679,7 @@ QBitmap QPixmap::mask() const
|
|||||||
*/
|
*/
|
||||||
int QPixmap::defaultDepth()
|
int QPixmap::defaultDepth()
|
||||||
{
|
{
|
||||||
#if defined(Q_WS_QWS)
|
return 32; // LITE: ### use QPlatformScreen (we should do that in general)
|
||||||
return QScreen::instance()->depth();
|
|
||||||
#elif defined(Q_WS_X11)
|
|
||||||
return QX11Info::appDepth();
|
|
||||||
#elif defined(Q_WS_WINCE)
|
|
||||||
return QColormap::instance().depth();
|
|
||||||
#elif defined(Q_WS_WIN)
|
|
||||||
return 32; // XXX
|
|
||||||
#elif defined(Q_WS_MAC)
|
|
||||||
return 32;
|
|
||||||
#elif defined(Q_OS_SYMBIAN)
|
|
||||||
return S60->screenDepth;
|
|
||||||
#elif defined(Q_WS_QPA)
|
|
||||||
return 32; //LITE: ### use graphicssystem (we should do that in general)
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1834,38 +1716,10 @@ void QPixmap::detach()
|
|||||||
if (data->is_cached && data->ref == 1)
|
if (data->is_cached && data->ref == 1)
|
||||||
QImagePixmapCleanupHooks::executePixmapDataModificationHooks(data.data());
|
QImagePixmapCleanupHooks::executePixmapDataModificationHooks(data.data());
|
||||||
|
|
||||||
#if defined(Q_WS_MAC)
|
|
||||||
QMacPixmapData *macData = id == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(pd) : 0;
|
|
||||||
if (macData) {
|
|
||||||
if (macData->cg_mask) {
|
|
||||||
CGImageRelease(macData->cg_mask);
|
|
||||||
macData->cg_mask = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (data->ref != 1) {
|
if (data->ref != 1) {
|
||||||
*this = copy();
|
*this = copy();
|
||||||
}
|
}
|
||||||
++data->detach_no;
|
++data->detach_no;
|
||||||
|
|
||||||
#if defined(Q_WS_X11)
|
|
||||||
if (pd->classId() == QPixmapData::X11Class) {
|
|
||||||
QX11PixmapData *d = static_cast<QX11PixmapData*>(pd);
|
|
||||||
d->flags &= ~QX11PixmapData::Uninitialized;
|
|
||||||
|
|
||||||
// reset the cache data
|
|
||||||
if (d->hd2) {
|
|
||||||
XFreePixmap(X11->display, d->hd2);
|
|
||||||
d->hd2 = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif defined(Q_WS_MAC)
|
|
||||||
if (macData) {
|
|
||||||
macData->macReleaseCGImageRef();
|
|
||||||
macData->uninit = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1958,12 +1812,7 @@ QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionF
|
|||||||
*/
|
*/
|
||||||
QPixmapData* QPixmap::pixmapData() const
|
QPixmapData* QPixmap::pixmapData() const
|
||||||
{
|
{
|
||||||
if (data) {
|
return data.data();
|
||||||
QPixmapData* pm = data.data();
|
|
||||||
return pm->runtimeData() ? pm->runtimeData() : pm;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,11 +52,6 @@
|
|||||||
|
|
||||||
QT_BEGIN_HEADER
|
QT_BEGIN_HEADER
|
||||||
|
|
||||||
#if defined(Q_OS_SYMBIAN)
|
|
||||||
class CFbsBitmap;
|
|
||||||
class RSgImage;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QT_MODULE(Gui)
|
QT_MODULE(Gui)
|
||||||
@ -109,24 +104,19 @@ public:
|
|||||||
QBitmap mask() const;
|
QBitmap mask() const;
|
||||||
void setMask(const QBitmap &);
|
void setMask(const QBitmap &);
|
||||||
|
|
||||||
QPixmap alphaChannel() const;
|
|
||||||
void setAlphaChannel(const QPixmap &);
|
|
||||||
|
|
||||||
bool hasAlpha() const;
|
bool hasAlpha() const;
|
||||||
bool hasAlphaChannel() const;
|
bool hasAlphaChannel() const;
|
||||||
|
|
||||||
#ifndef QT_NO_IMAGE_HEURISTIC_MASK
|
#ifndef QT_NO_IMAGE_HEURISTIC_MASK
|
||||||
QBitmap createHeuristicMask(bool clipTight = true) const;
|
QBitmap createHeuristicMask(bool clipTight = true) const;
|
||||||
#endif
|
#endif
|
||||||
QBitmap createMaskFromColor(const QColor &maskColor) const; // ### Qt 5: remove
|
QBitmap createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode = Qt::MaskInColor) const;
|
||||||
QBitmap createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode) const;
|
|
||||||
|
|
||||||
static QPixmap grabWindow(WId, int x=0, int y=0, int w=-1, int h=-1);
|
static QPixmap grabWindow(WId, int x=0, int y=0, int w=-1, int h=-1);
|
||||||
static QPixmap grabWidget(QPaintDevice *widget, const QRect &rect);
|
static QPixmap grabWidget(QPaintDevice *widget, const QRect &rect);
|
||||||
static inline QPixmap grabWidget(QPaintDevice *widget, int x=0, int y=0, int w=-1, int h=-1)
|
static inline QPixmap grabWidget(QPaintDevice *widget, int x=0, int y=0, int w=-1, int h=-1)
|
||||||
{ return grabWidget(widget, QRect(x, y, w, h)); }
|
{ return grabWidget(widget, QRect(x, y, w, h)); }
|
||||||
|
|
||||||
|
|
||||||
inline QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode = Qt::IgnoreAspectRatio,
|
inline QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode = Qt::IgnoreAspectRatio,
|
||||||
Qt::TransformationMode mode = Qt::FastTransformation) const
|
Qt::TransformationMode mode = Qt::FastTransformation) const
|
||||||
{ return scaled(QSize(w, h), aspectMode, mode); }
|
{ return scaled(QSize(w, h), aspectMode, mode); }
|
||||||
@ -151,32 +141,6 @@ public:
|
|||||||
|
|
||||||
bool convertFromImage(const QImage &img, Qt::ImageConversionFlags flags = Qt::AutoColor);
|
bool convertFromImage(const QImage &img, Qt::ImageConversionFlags flags = Qt::AutoColor);
|
||||||
|
|
||||||
#if defined(Q_WS_WIN)
|
|
||||||
enum HBitmapFormat {
|
|
||||||
NoAlpha,
|
|
||||||
PremultipliedAlpha,
|
|
||||||
Alpha
|
|
||||||
};
|
|
||||||
|
|
||||||
HBITMAP toWinHBITMAP(HBitmapFormat format = NoAlpha) const;
|
|
||||||
HICON toWinHICON() const;
|
|
||||||
|
|
||||||
static QPixmap fromWinHBITMAP(HBITMAP hbitmap, HBitmapFormat format = NoAlpha);
|
|
||||||
static QPixmap fromWinHICON(HICON hicon);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Q_WS_MAC)
|
|
||||||
CGImageRef toMacCGImageRef() const;
|
|
||||||
static QPixmap fromMacCGImageRef(CGImageRef image);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Q_OS_SYMBIAN)
|
|
||||||
CFbsBitmap *toSymbianCFbsBitmap() const;
|
|
||||||
static QPixmap fromSymbianCFbsBitmap(CFbsBitmap *bitmap);
|
|
||||||
RSgImage* toSymbianRSgImage() const;
|
|
||||||
static QPixmap fromSymbianRSgImage(RSgImage *sgImage);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline QPixmap copy(int x, int y, int width, int height) const;
|
inline QPixmap copy(int x, int y, int width, int height) const;
|
||||||
QPixmap copy(const QRect &rect = QRect()) const;
|
QPixmap copy(const QRect &rect = QRect()) const;
|
||||||
|
|
||||||
@ -191,36 +155,15 @@ public:
|
|||||||
|
|
||||||
bool isQBitmap() const;
|
bool isQBitmap() const;
|
||||||
|
|
||||||
#if defined(Q_WS_QWS)
|
|
||||||
const uchar *qwsBits() const;
|
|
||||||
int qwsBytesPerLine() const;
|
|
||||||
QRgb *clut() const;
|
|
||||||
#ifdef QT_DEPRECATED
|
|
||||||
QT_DEPRECATED int numCols() const;
|
|
||||||
#endif
|
|
||||||
int colorCount() const;
|
|
||||||
#elif defined(Q_WS_MAC)
|
|
||||||
Qt::HANDLE macQDHandle() const;
|
|
||||||
Qt::HANDLE macQDAlphaHandle() const;
|
|
||||||
Qt::HANDLE macCGHandle() const;
|
|
||||||
#elif defined(Q_WS_X11)
|
|
||||||
enum ShareMode { ImplicitlyShared, ExplicitlyShared };
|
|
||||||
|
|
||||||
static QPixmap fromX11Pixmap(Qt::HANDLE pixmap, ShareMode mode = ImplicitlyShared);
|
|
||||||
static int x11SetDefaultScreen(int screen);
|
|
||||||
void x11SetScreen(int screen);
|
|
||||||
const QX11Info &x11Info() const;
|
|
||||||
Qt::HANDLE x11PictureHandle() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Q_WS_X11) || defined(Q_WS_QWS)
|
|
||||||
Qt::HANDLE handle() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QPaintEngine *paintEngine() const;
|
QPaintEngine *paintEngine() const;
|
||||||
|
|
||||||
inline bool operator!() const { return isNull(); }
|
inline bool operator!() const { return isNull(); }
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 0)
|
||||||
|
QT_DEPRECATED inline QPixmap alphaChannel() const;
|
||||||
|
QT_DEPRECATED inline void setAlphaChannel(const QPixmap &);
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int metric(PaintDeviceMetric) const;
|
int metric(PaintDeviceMetric) const;
|
||||||
|
|
||||||
@ -229,41 +172,20 @@ private:
|
|||||||
|
|
||||||
bool doImageIO(QImageWriter *io, int quality) const;
|
bool doImageIO(QImageWriter *io, int quality) const;
|
||||||
|
|
||||||
// ### Qt5: remove the following three lines
|
|
||||||
enum Type { PixmapType, BitmapType }; // must match QPixmapData::PixelType
|
|
||||||
QPixmap(const QSize &s, Type);
|
|
||||||
void init(int, int, Type = PixmapType);
|
|
||||||
|
|
||||||
QPixmap(const QSize &s, int type);
|
QPixmap(const QSize &s, int type);
|
||||||
void init(int, int, int);
|
void init(int, int, int);
|
||||||
void deref();
|
void deref();
|
||||||
#if defined(Q_WS_WIN)
|
|
||||||
void initAlphaPixmap(uchar *bytes, int length, struct tagBITMAPINFO *bmi);
|
|
||||||
#endif
|
|
||||||
Q_DUMMY_COMPARISON_OPERATOR(QPixmap)
|
Q_DUMMY_COMPARISON_OPERATOR(QPixmap)
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
friend CGContextRef qt_mac_cg_context(const QPaintDevice*);
|
|
||||||
friend CGImageRef qt_mac_create_imagemask(const QPixmap&, const QRectF&);
|
|
||||||
friend IconRef qt_mac_create_iconref(const QPixmap&);
|
|
||||||
friend quint32 *qt_mac_pixmap_get_base(const QPixmap*);
|
|
||||||
friend int qt_mac_pixmap_get_bytes_per_line(const QPixmap*);
|
|
||||||
#endif
|
|
||||||
friend class QPixmapData;
|
friend class QPixmapData;
|
||||||
friend class QX11PixmapData;
|
|
||||||
friend class QMacPixmapData;
|
|
||||||
friend class QS60PixmapData;
|
|
||||||
friend class QBitmap;
|
friend class QBitmap;
|
||||||
friend class QPaintDevice;
|
friend class QPaintDevice;
|
||||||
friend class QPainter;
|
friend class QPainter;
|
||||||
friend class QGLWidget;
|
friend class QGLWidget;
|
||||||
friend class QX11PaintEngine;
|
|
||||||
friend class QCoreGraphicsPaintEngine;
|
|
||||||
friend class QWidgetPrivate;
|
friend class QWidgetPrivate;
|
||||||
friend class QRasterBuffer;
|
friend class QRasterBuffer;
|
||||||
#if !defined(QT_NO_DATASTREAM)
|
#if !defined(QT_NO_DATASTREAM)
|
||||||
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPixmap &);
|
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPixmap &);
|
||||||
#endif
|
#endif
|
||||||
friend Q_GUI_EXPORT qint64 qt_pixmap_id(const QPixmap &pixmap);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QPixmapData* pixmapData() const;
|
QPixmapData* pixmapData() const;
|
||||||
@ -291,6 +213,22 @@ inline bool QPixmap::loadFromData(const QByteArray &buf, const char *format,
|
|||||||
return loadFromData(reinterpret_cast<const uchar *>(buf.constData()), buf.size(), format, flags);
|
return loadFromData(reinterpret_cast<const uchar *>(buf.constData()), buf.size(), format, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 0)
|
||||||
|
inline QPixmap QPixmap::alphaChannel() const
|
||||||
|
{
|
||||||
|
return toImage().alphaChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void QPixmap::setAlphaChannel(const QPixmap &p)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
QImage image = data->toImage();
|
||||||
|
image.setAlphaChannel(p.toImage());
|
||||||
|
data->fromImage(image);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
QPixmap stream functions
|
QPixmap stream functions
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
@ -58,9 +58,6 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08,
|
|
||||||
0x10, 0x20, 0x40, 0x80 };
|
|
||||||
|
|
||||||
QPixmap qt_toRasterPixmap(const QImage &image)
|
QPixmap qt_toRasterPixmap(const QImage &image)
|
||||||
{
|
{
|
||||||
QPixmapData *data =
|
QPixmapData *data =
|
||||||
@ -265,45 +262,6 @@ void QRasterPixmapData::fill(const QColor &color)
|
|||||||
image.fill(pixel);
|
image.fill(pixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QRasterPixmapData::setMask(const QBitmap &mask)
|
|
||||||
{
|
|
||||||
if (mask.size().isEmpty()) {
|
|
||||||
if (image.depth() != 1) { // hw: ????
|
|
||||||
image = image.convertToFormat(QImage::Format_RGB32);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const int w = image.width();
|
|
||||||
const int h = image.height();
|
|
||||||
|
|
||||||
switch (image.depth()) {
|
|
||||||
case 1: {
|
|
||||||
const QImage imageMask = mask.toImage().convertToFormat(image.format());
|
|
||||||
for (int y = 0; y < h; ++y) {
|
|
||||||
const uchar *mscan = imageMask.scanLine(y);
|
|
||||||
uchar *tscan = image.scanLine(y);
|
|
||||||
int bytesPerLine = image.bytesPerLine();
|
|
||||||
for (int i = 0; i < bytesPerLine; ++i)
|
|
||||||
tscan[i] &= mscan[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
const QImage imageMask = mask.toImage().convertToFormat(QImage::Format_MonoLSB);
|
|
||||||
image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
|
||||||
for (int y = 0; y < h; ++y) {
|
|
||||||
const uchar *mscan = imageMask.scanLine(y);
|
|
||||||
QRgb *tscan = (QRgb *)image.scanLine(y);
|
|
||||||
for (int x = 0; x < w; ++x) {
|
|
||||||
if (!(mscan[x>>3] & qt_pixmap_bit_mask[x&7]))
|
|
||||||
tscan[x] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QRasterPixmapData::hasAlphaChannel() const
|
bool QRasterPixmapData::hasAlphaChannel() const
|
||||||
{
|
{
|
||||||
return image.hasAlphaChannel();
|
return image.hasAlphaChannel();
|
||||||
@ -337,11 +295,6 @@ QImage QRasterPixmapData::toImage(const QRect &rect) const
|
|||||||
return image.copy(clipped);
|
return image.copy(clipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QRasterPixmapData::setAlphaChannel(const QPixmap &alphaChannel)
|
|
||||||
{
|
|
||||||
image.setAlphaChannel(alphaChannel.toImage());
|
|
||||||
}
|
|
||||||
|
|
||||||
QPaintEngine* QRasterPixmapData::paintEngine() const
|
QPaintEngine* QRasterPixmapData::paintEngine() const
|
||||||
{
|
{
|
||||||
return image.paintEngine();
|
return image.paintEngine();
|
||||||
|
@ -79,9 +79,7 @@ public:
|
|||||||
void copy(const QPixmapData *data, const QRect &rect);
|
void copy(const QPixmapData *data, const QRect &rect);
|
||||||
bool scroll(int dx, int dy, const QRect &rect);
|
bool scroll(int dx, int dy, const QRect &rect);
|
||||||
void fill(const QColor &color);
|
void fill(const QColor &color);
|
||||||
void setMask(const QBitmap &mask);
|
|
||||||
bool hasAlphaChannel() const;
|
bool hasAlphaChannel() const;
|
||||||
void setAlphaChannel(const QPixmap &alphaChannel);
|
|
||||||
QImage toImage() const;
|
QImage toImage() const;
|
||||||
QImage toImage(const QRect &rect) const;
|
QImage toImage(const QRect &rect) const;
|
||||||
QPaintEngine* paintEngine() const;
|
QPaintEngine* paintEngine() const;
|
||||||
|
@ -48,9 +48,6 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08,
|
|
||||||
0x10, 0x20, 0x40, 0x80 };
|
|
||||||
|
|
||||||
QPixmapData *QPixmapData::create(int w, int h, PixelType type)
|
QPixmapData *QPixmapData::create(int w, int h, PixelType type)
|
||||||
{
|
{
|
||||||
QPixmapData *data = QGuiApplicationPrivate::platformIntegration()->createPixmapData(static_cast<QPixmapData::PixelType>(type));
|
QPixmapData *data = QGuiApplicationPrivate::platformIntegration()->createPixmapData(static_cast<QPixmapData::PixelType>(type));
|
||||||
@ -153,99 +150,12 @@ bool QPixmapData::scroll(int dx, int dy, const QRect &rect)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QPixmapData::setMask(const QBitmap &mask)
|
|
||||||
{
|
|
||||||
if (mask.size().isEmpty()) {
|
|
||||||
if (depth() != 1)
|
|
||||||
fromImage(toImage().convertToFormat(QImage::Format_RGB32),
|
|
||||||
Qt::AutoColor);
|
|
||||||
} else {
|
|
||||||
QImage image = toImage();
|
|
||||||
const int w = image.width();
|
|
||||||
const int h = image.height();
|
|
||||||
|
|
||||||
switch (image.depth()) {
|
|
||||||
case 1: {
|
|
||||||
const QImage imageMask = mask.toImage().convertToFormat(image.format());
|
|
||||||
for (int y = 0; y < h; ++y) {
|
|
||||||
const uchar *mscan = imageMask.scanLine(y);
|
|
||||||
uchar *tscan = image.scanLine(y);
|
|
||||||
int bytesPerLine = image.bytesPerLine();
|
|
||||||
for (int i = 0; i < bytesPerLine; ++i)
|
|
||||||
tscan[i] &= mscan[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
const QImage imageMask = mask.toImage().convertToFormat(QImage::Format_MonoLSB);
|
|
||||||
image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
|
||||||
for (int y = 0; y < h; ++y) {
|
|
||||||
const uchar *mscan = imageMask.scanLine(y);
|
|
||||||
QRgb *tscan = (QRgb *)image.scanLine(y);
|
|
||||||
for (int x = 0; x < w; ++x) {
|
|
||||||
if (!(mscan[x>>3] & qt_pixmap_bit_mask[x&7]))
|
|
||||||
tscan[x] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fromImage(image, Qt::AutoColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QBitmap QPixmapData::mask() const
|
|
||||||
{
|
|
||||||
if (!hasAlphaChannel())
|
|
||||||
return QBitmap();
|
|
||||||
|
|
||||||
const QImage img = toImage();
|
|
||||||
const QImage image = (img.depth() < 32 ? img.convertToFormat(QImage::Format_ARGB32_Premultiplied) : img);
|
|
||||||
const int w = image.width();
|
|
||||||
const int h = image.height();
|
|
||||||
|
|
||||||
QImage mask(w, h, QImage::Format_MonoLSB);
|
|
||||||
if (mask.isNull()) // allocation failed
|
|
||||||
return QBitmap();
|
|
||||||
|
|
||||||
mask.setColorCount(2);
|
|
||||||
mask.setColor(0, QColor(Qt::color0).rgba());
|
|
||||||
mask.setColor(1, QColor(Qt::color1).rgba());
|
|
||||||
|
|
||||||
const int bpl = mask.bytesPerLine();
|
|
||||||
|
|
||||||
for (int y = 0; y < h; ++y) {
|
|
||||||
const QRgb *src = reinterpret_cast<const QRgb*>(image.scanLine(y));
|
|
||||||
uchar *dest = mask.scanLine(y);
|
|
||||||
memset(dest, 0, bpl);
|
|
||||||
for (int x = 0; x < w; ++x) {
|
|
||||||
if (qAlpha(*src) > 0)
|
|
||||||
dest[x >> 3] |= qt_pixmap_bit_mask[x & 7];
|
|
||||||
++src;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return QBitmap::fromImage(mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap QPixmapData::transformed(const QTransform &matrix,
|
QPixmap QPixmapData::transformed(const QTransform &matrix,
|
||||||
Qt::TransformationMode mode) const
|
Qt::TransformationMode mode) const
|
||||||
{
|
{
|
||||||
return QPixmap::fromImage(toImage().transformed(matrix, mode));
|
return QPixmap::fromImage(toImage().transformed(matrix, mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QPixmapData::setAlphaChannel(const QPixmap &alphaChannel)
|
|
||||||
{
|
|
||||||
QImage image = toImage();
|
|
||||||
image.setAlphaChannel(alphaChannel.toImage());
|
|
||||||
fromImage(image, Qt::AutoColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap QPixmapData::alphaChannel() const
|
|
||||||
{
|
|
||||||
return QPixmap::fromImage(toImage().alphaChannel());
|
|
||||||
}
|
|
||||||
|
|
||||||
void QPixmapData::setSerialNumber(int serNo)
|
void QPixmapData::setSerialNumber(int serNo)
|
||||||
{
|
{
|
||||||
ser_no = serNo;
|
ser_no = serNo;
|
||||||
|
@ -68,17 +68,9 @@ public:
|
|||||||
// Must match QPixmap::Type
|
// Must match QPixmap::Type
|
||||||
PixmapType, BitmapType
|
PixmapType, BitmapType
|
||||||
};
|
};
|
||||||
#if defined(Q_OS_SYMBIAN)
|
|
||||||
enum NativeType {
|
enum ClassId { RasterClass, DirectFBClass,
|
||||||
FbsBitmap,
|
BlitterClass, CustomClass = 1024 };
|
||||||
SgImage,
|
|
||||||
VolatileImage,
|
|
||||||
NativeImageHandleProvider
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
enum ClassId { RasterClass, X11Class, MacClass, DirectFBClass,
|
|
||||||
OpenGLClass, OpenVGClass, RuntimeClass, BlitterClass,
|
|
||||||
CustomClass = 1024 };
|
|
||||||
|
|
||||||
QPixmapData(PixelType pixelType, int classId);
|
QPixmapData(PixelType pixelType, int classId);
|
||||||
virtual ~QPixmapData();
|
virtual ~QPixmapData();
|
||||||
@ -101,13 +93,11 @@ public:
|
|||||||
|
|
||||||
virtual int metric(QPaintDevice::PaintDeviceMetric metric) const = 0;
|
virtual int metric(QPaintDevice::PaintDeviceMetric metric) const = 0;
|
||||||
virtual void fill(const QColor &color) = 0;
|
virtual void fill(const QColor &color) = 0;
|
||||||
virtual QBitmap mask() const;
|
|
||||||
virtual void setMask(const QBitmap &mask);
|
|
||||||
virtual bool hasAlphaChannel() const = 0;
|
virtual bool hasAlphaChannel() const = 0;
|
||||||
virtual QPixmap transformed(const QTransform &matrix,
|
virtual QPixmap transformed(const QTransform &matrix,
|
||||||
Qt::TransformationMode mode) const;
|
Qt::TransformationMode mode) const;
|
||||||
virtual void setAlphaChannel(const QPixmap &alphaChannel);
|
|
||||||
virtual QPixmap alphaChannel() const;
|
|
||||||
virtual QImage toImage() const = 0;
|
virtual QImage toImage() const = 0;
|
||||||
virtual QImage toImage(const QRect &rect) const;
|
virtual QImage toImage(const QRect &rect) const;
|
||||||
virtual QPaintEngine* paintEngine() const = 0;
|
virtual QPaintEngine* paintEngine() const = 0;
|
||||||
@ -121,7 +111,6 @@ public:
|
|||||||
|
|
||||||
inline int width() const { return w; }
|
inline int width() const { return w; }
|
||||||
inline int height() const { return h; }
|
inline int height() const { return h; }
|
||||||
QT_DEPRECATED inline int numColors() const { return metric(QPaintDevice::PdmNumColors); }
|
|
||||||
inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); }
|
inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); }
|
||||||
inline int depth() const { return d; }
|
inline int depth() const { return d; }
|
||||||
inline bool isNull() const { return is_null; }
|
inline bool isNull() const { return is_null; }
|
||||||
@ -134,15 +123,8 @@ public:
|
|||||||
| ((qint64) detach_no));
|
| ((qint64) detach_no));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_SYMBIAN)
|
|
||||||
virtual void* toNativeType(NativeType type);
|
|
||||||
virtual void fromNativeType(void* pixmap, NativeType type);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QPixmapData *create(int w, int h, PixelType type);
|
static QPixmapData *create(int w, int h, PixelType type);
|
||||||
|
|
||||||
virtual QPixmapData *runtimeData() const { return 0; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void setSerialNumber(int serNo);
|
void setSerialNumber(int serNo);
|
||||||
@ -153,8 +135,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class QPixmap;
|
friend class QPixmap;
|
||||||
friend class QX11PixmapData;
|
|
||||||
friend class QS60PixmapData;
|
|
||||||
friend class QImagePixmapCleanupHooks; // Needs to set is_cached
|
friend class QImagePixmapCleanupHooks; // Needs to set is_cached
|
||||||
friend class QGLTextureCache; //Needs to check the reference count
|
friend class QGLTextureCache; //Needs to check the reference count
|
||||||
friend class QExplicitlySharedDataPointer<QPixmapData>;
|
friend class QExplicitlySharedDataPointer<QPixmapData>;
|
||||||
|
@ -200,15 +200,6 @@ void *QVolatileImage::duplicateNativeImage() const
|
|||||||
return d->duplicateNativeImage();
|
return d->duplicateNativeImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QVolatileImage::setAlphaChannel(const QPixmap &alphaChannel)
|
|
||||||
{
|
|
||||||
ensureFormat(QImage::Format_ARGB32_Premultiplied);
|
|
||||||
beginDataAccess();
|
|
||||||
imageRef().setAlphaChannel(alphaChannel.toImage());
|
|
||||||
endDataAccess();
|
|
||||||
d->ensureImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QVolatileImage::fill(uint pixelValue)
|
void QVolatileImage::fill(uint pixelValue)
|
||||||
{
|
{
|
||||||
beginDataAccess();
|
beginDataAccess();
|
||||||
|
@ -87,7 +87,6 @@ public:
|
|||||||
QImage toImage() const;
|
QImage toImage() const;
|
||||||
QImage &imageRef();
|
QImage &imageRef();
|
||||||
QPaintEngine *paintEngine();
|
QPaintEngine *paintEngine();
|
||||||
void setAlphaChannel(const QPixmap &alphaChannel);
|
|
||||||
void fill(uint pixelValue);
|
void fill(uint pixelValue);
|
||||||
void *duplicateNativeImage() const;
|
void *duplicateNativeImage() const;
|
||||||
void copyFrom(QVolatileImage *source, const QRect &rect);
|
void copyFrom(QVolatileImage *source, const QRect &rect);
|
||||||
|
@ -580,7 +580,7 @@ void QPlatformCursorImage::set(const uchar *data, const uchar *mask,
|
|||||||
if (!width || !height || !data || !mask || cursorImage.isNull())
|
if (!width || !height || !data || !mask || cursorImage.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cursorImage.setNumColors(3);
|
cursorImage.setColorCount(3);
|
||||||
cursorImage.setColor(0, 0xff000000);
|
cursorImage.setColor(0, 0xff000000);
|
||||||
cursorImage.setColor(1, 0xffffffff);
|
cursorImage.setColor(1, 0xffffffff);
|
||||||
cursorImage.setColor(2, 0x00000000);
|
cursorImage.setColor(2, 0x00000000);
|
||||||
|
@ -68,9 +68,6 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
extern qint64 qt_pixmap_id(const QPixmap &pixmap);
|
|
||||||
extern qint64 qt_image_id(const QImage &image);
|
|
||||||
|
|
||||||
//#define FONT_DUMP
|
//#define FONT_DUMP
|
||||||
|
|
||||||
// might be helpful for smooth transforms of images
|
// might be helpful for smooth transforms of images
|
||||||
@ -469,7 +466,7 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
|
|||||||
return 0;
|
return 0;
|
||||||
QImage image = brush.texture().toImage();
|
QImage image = brush.texture().toImage();
|
||||||
bool bitmap = true;
|
bool bitmap = true;
|
||||||
imageObject = addImage(image, &bitmap, qt_pixmap_id(brush.texture()));
|
imageObject = addImage(image, &bitmap, brush.texture().cacheKey());
|
||||||
if (imageObject != -1) {
|
if (imageObject != -1) {
|
||||||
QImage::Format f = image.format();
|
QImage::Format f = image.format();
|
||||||
if (f != QImage::Format_MonoLSB && f != QImage::Format_Mono) {
|
if (f != QImage::Format_MonoLSB && f != QImage::Format_Mono) {
|
||||||
|
@ -589,7 +589,6 @@ QImage ICOReader::iconAt(int index)
|
|||||||
mask.setColor(1, qRgba(0 ,0 ,0 ,0xff));
|
mask.setColor(1, qRgba(0 ,0 ,0 ,0xff));
|
||||||
read1BitBMP(mask);
|
read1BitBMP(mask);
|
||||||
if (!mask.isNull()) {
|
if (!mask.isNull()) {
|
||||||
img = QImage(image.width(), image.height(), QImage::Format_ARGB32 );
|
|
||||||
img = image;
|
img = image;
|
||||||
img.setAlphaChannel(mask);
|
img.setAlphaChannel(mask);
|
||||||
// (Luckily, it seems that setAlphaChannel() does not ruin the alpha values
|
// (Luckily, it seems that setAlphaChannel() does not ruin the alpha values
|
||||||
|
@ -1044,7 +1044,7 @@ static QString qPixmapSerial(quint64 i, bool enabled)
|
|||||||
*/
|
*/
|
||||||
QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette, bool enabled) const
|
QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette, bool enabled) const
|
||||||
{
|
{
|
||||||
QString key = qPixmapSerial(qt_pixmap_id(pixmap), enabled);
|
QString key = qPixmapSerial(pixmap.cacheKey(), enabled);
|
||||||
QPixmap *pm = QPixmapCache::find(key);
|
QPixmap *pm = QPixmapCache::find(key);
|
||||||
if (!pm) {
|
if (!pm) {
|
||||||
QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
||||||
|
@ -102,9 +102,6 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void swap();
|
void swap();
|
||||||
|
|
||||||
void setAlphaChannel_data();
|
|
||||||
void setAlphaChannel();
|
|
||||||
|
|
||||||
void fromImage_data();
|
void fromImage_data();
|
||||||
void fromImage();
|
void fromImage();
|
||||||
|
|
||||||
@ -267,79 +264,6 @@ void tst_QPixmap::swap()
|
|||||||
QCOMPARE(p2.size(), QSize(16,16));
|
QCOMPARE(p2.size(), QSize(16,16));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QPixmap::setAlphaChannel_data()
|
|
||||||
{
|
|
||||||
QTest::addColumn<int>("red");
|
|
||||||
QTest::addColumn<int>("green");
|
|
||||||
QTest::addColumn<int>("blue");
|
|
||||||
QTest::addColumn<int>("alpha");
|
|
||||||
|
|
||||||
QTest::newRow("red 0") << 255 << 0 << 0 << 0;
|
|
||||||
QTest::newRow("red 24") << 255 << 0 << 0 << 24;
|
|
||||||
QTest::newRow("red 124") << 255 << 0 << 0 << 124;
|
|
||||||
QTest::newRow("red 255") << 255 << 0 << 0 << 255;
|
|
||||||
|
|
||||||
QTest::newRow("green 0") << 0 << 255 << 0 << 0;
|
|
||||||
QTest::newRow("green 24") << 0 << 255 << 0 << 24;
|
|
||||||
QTest::newRow("green 124") << 0 << 255 << 0 << 124;
|
|
||||||
QTest::newRow("green 255") << 0 << 255 << 0 << 255;
|
|
||||||
|
|
||||||
QTest::newRow("blue 0") << 0 << 0 << 255 << 0;
|
|
||||||
QTest::newRow("blue 24") << 0 << 0 << 255 << 24;
|
|
||||||
QTest::newRow("blue 124") << 0 << 0 << 255 << 124;
|
|
||||||
QTest::newRow("blue 255") << 0 << 0 << 255 << 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QPixmap::setAlphaChannel()
|
|
||||||
{
|
|
||||||
QFETCH(int, red);
|
|
||||||
QFETCH(int, green);
|
|
||||||
QFETCH(int, blue);
|
|
||||||
QFETCH(int, alpha);
|
|
||||||
|
|
||||||
int width = 100;
|
|
||||||
int height = 100;
|
|
||||||
|
|
||||||
QPixmap pixmap(width, height);
|
|
||||||
pixmap.fill(QColor(red, green, blue));
|
|
||||||
|
|
||||||
QPixmap alphaChannel(width, height);
|
|
||||||
alphaChannel.fill(QColor(alpha, alpha, alpha));
|
|
||||||
pixmap.setAlphaChannel(alphaChannel);
|
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
|
||||||
if (pixmap.pixmapData()->classId() == QPixmapData::X11Class && !pixmap.x11PictureHandle())
|
|
||||||
QSKIP("Requires XRender support", SkipAll);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QImage result;
|
|
||||||
bool ok = true;
|
|
||||||
|
|
||||||
QPixmap outAlpha = pixmap.alphaChannel();
|
|
||||||
QCOMPARE(outAlpha.size(), pixmap.size());
|
|
||||||
|
|
||||||
result = outAlpha.toImage().convertToFormat(QImage::Format_ARGB32);;
|
|
||||||
for (int y = 0; y < height; ++y) {
|
|
||||||
for (int x = 0; x < width; ++x) {
|
|
||||||
ok &= qGray(result.pixel(x, y)) == alpha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QVERIFY(ok);
|
|
||||||
|
|
||||||
result = pixmap.toImage().convertToFormat(QImage::Format_ARGB32);
|
|
||||||
QRgb expected = alpha == 0 ? 0 : qRgba(red, green, blue, alpha);
|
|
||||||
for (int y = 0; y < height; ++y) {
|
|
||||||
for (int x = 0; x < width; ++x) {
|
|
||||||
if (result.colorCount() > 0) {
|
|
||||||
ok &= result.pixelIndex(x, y) == expected;
|
|
||||||
} else {
|
|
||||||
ok &= result.pixel(x, y) == expected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QVERIFY(ok);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QPixmap::fromImage_data()
|
void tst_QPixmap::fromImage_data()
|
||||||
{
|
{
|
||||||
bool is16bit = false;
|
bool is16bit = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user