QPdf::addImage(): avoid a QImage detach when it's in an acceptable Format
Don't detach QImage, when it's in Format_Mono or Format_ARG32. Use QImage::constScanLine() instead of QImage::scanLine(). Change-Id: I30fcafb576aea3189637a40fd75f77c70017ba46 Reviewed-by: John Layt <jlayt@kde.org> Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>bb10
parent
aabe80ae28
commit
1a32cc0ae4
|
|
@ -2362,7 +2362,7 @@ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_n
|
|||
data.resize(bytesPerLine * h);
|
||||
char *rawdata = data.data();
|
||||
for (int y = 0; y < h; ++y) {
|
||||
memcpy(rawdata, image.scanLine(y), bytesPerLine);
|
||||
memcpy(rawdata, image.constScanLine(y), bytesPerLine);
|
||||
rawdata += bytesPerLine;
|
||||
}
|
||||
object = writeImage(data, w, h, d, 0, 0);
|
||||
|
|
@ -2384,7 +2384,7 @@ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_n
|
|||
softMaskData.resize(w * h);
|
||||
uchar *sdata = (uchar *)softMaskData.data();
|
||||
for (int y = 0; y < h; ++y) {
|
||||
const QRgb *rgb = (const QRgb *)image.scanLine(y);
|
||||
const QRgb *rgb = (const QRgb *)image.constScanLine(y);
|
||||
for (int x = 0; x < w; ++x) {
|
||||
uchar alpha = qAlpha(*rgb);
|
||||
*sdata++ = alpha;
|
||||
|
|
@ -2400,7 +2400,7 @@ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_n
|
|||
softMaskData.resize(w * h);
|
||||
uchar *sdata = (uchar *)softMaskData.data();
|
||||
for (int y = 0; y < h; ++y) {
|
||||
const QRgb *rgb = (const QRgb *)image.scanLine(y);
|
||||
const QRgb *rgb = (const QRgb *)image.constScanLine(y);
|
||||
if (grayscale) {
|
||||
for (int x = 0; x < w; ++x) {
|
||||
*(data++) = qGray(*rgb);
|
||||
|
|
|
|||
Loading…
Reference in New Issue