QImage: optimize convertWithPalette()
The old code got a QMap serialized as a QString and parsed it to re-create the same map. Just copy the map. Change-Id: Ic71b9fa9d822eab53fe37dfb4d76223cd69ac057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
871e2981dd
commit
5c1446e3fa
@ -2149,12 +2149,7 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format,
|
||||
QImage dest(src.size(), format);
|
||||
dest.setColorTable(clut);
|
||||
|
||||
QString textsKeys = src.text();
|
||||
const auto textKeyList = textsKeys.splitRef(QLatin1Char('\n'), Qt::SkipEmptyParts);
|
||||
for (const auto &textKey : textKeyList) {
|
||||
const auto textKeySplitted = textKey.split(QLatin1String(": "));
|
||||
dest.setText(textKeySplitted[0].toString(), textKeySplitted[1].toString());
|
||||
}
|
||||
QImageData::get(dest)->text = QImageData::get(src)->text;
|
||||
|
||||
int h = src.height();
|
||||
int w = src.width();
|
||||
|
@ -385,6 +385,7 @@ private:
|
||||
friend class QRasterPlatformPixmap;
|
||||
friend class QBlittablePlatformPixmap;
|
||||
friend class QPixmapCacheEntry;
|
||||
friend struct QImageData;
|
||||
|
||||
public:
|
||||
typedef QImageData * DataPtr;
|
||||
|
@ -69,6 +69,9 @@ struct Q_GUI_EXPORT QImageData { // internal image data
|
||||
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 *get(QImage &img) noexcept { return img.d; }
|
||||
static const QImageData *get(const QImage &img) noexcept { return img.d; }
|
||||
|
||||
QAtomicInt ref;
|
||||
|
||||
int width;
|
||||
|
Loading…
Reference in New Issue
Block a user