mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -04:00
QImage: use rvalue overloads more
to reuse internal buffers
This commit is contained in:
parent
75e1280073
commit
485e084fa9
@ -714,9 +714,9 @@ bool QAVIFHandler::write(const QImage &image)
|
|||||||
if (save_depth == 8) {
|
if (save_depth == 8) {
|
||||||
save_depth = 10;
|
save_depth = 10;
|
||||||
if (tmpcolorimage.hasAlphaChannel()) {
|
if (tmpcolorimage.hasAlphaChannel()) {
|
||||||
tmpcolorimage = tmpcolorimage.convertToFormat(QImage::Format_RGBA64);
|
tmpcolorimage.convertTo(QImage::Format_RGBA64);
|
||||||
} else {
|
} else {
|
||||||
tmpcolorimage = tmpcolorimage.convertToFormat(QImage::Format_RGBX64);
|
tmpcolorimage.convertTo(QImage::Format_RGBX64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ bool EXRHandler::read(QImage *outImage)
|
|||||||
#endif // !EXR_ALLOW_LINEAR_COLORSPACE
|
#endif // !EXR_ALLOW_LINEAR_COLORSPACE
|
||||||
#endif // !EXR_USE_LEGACY_CONVERSIONS
|
#endif // !EXR_USE_LEGACY_CONVERSIONS
|
||||||
|
|
||||||
*outImage = image;
|
*outImage = std::move(image);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (const std::exception &exc) {
|
} catch (const std::exception &exc) {
|
||||||
|
@ -283,7 +283,7 @@ bool HDRHandler::read(QImage *outImage)
|
|||||||
// By setting the linear color space, programs that support profiles display HDR files as in GIMP and Photoshop.
|
// By setting the linear color space, programs that support profiles display HDR files as in GIMP and Photoshop.
|
||||||
img.setColorSpace(QColorSpace(QColorSpace::SRgbLinear));
|
img.setColorSpace(QColorSpace(QColorSpace::SRgbLinear));
|
||||||
|
|
||||||
*outImage = img;
|
*outImage = std::move(img);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,8 +383,7 @@ static bool readImage8(QImage &img, QDataStream &s, const PCXHEADER &header)
|
|||||||
while (flag != 12 && s.status() == QDataStream::Ok) {
|
while (flag != 12 && s.status() == QDataStream::Ok) {
|
||||||
s >> flag;
|
s >> flag;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
device->seek(device->size() - 769);
|
device->seek(device->size() - 769);
|
||||||
s >> flag;
|
s >> flag;
|
||||||
}
|
}
|
||||||
@ -613,7 +612,7 @@ static bool writeImage24(QImage &img, QDataStream &s, PCXHEADER &header)
|
|||||||
QByteArray b_buf(header.width(), 0);
|
QByteArray b_buf(header.width(), 0);
|
||||||
|
|
||||||
for (int y = 0; y < header.height(); ++y) {
|
for (int y = 0; y < header.height(); ++y) {
|
||||||
auto p = (QRgb*)img.scanLine(y);
|
auto p = (QRgb *)img.scanLine(y);
|
||||||
|
|
||||||
for (int x = 0; x < header.width(); ++x) {
|
for (int x = 0; x < header.width(); ++x) {
|
||||||
QRgb rgb = *p++;
|
QRgb rgb = *p++;
|
||||||
@ -684,7 +683,7 @@ bool PCXHandler::read(QImage *outImage)
|
|||||||
|
|
||||||
img.setDotsPerMeterX(qRound(header.HDpi / 25.4 * 1000));
|
img.setDotsPerMeterX(qRound(header.HDpi / 25.4 * 1000));
|
||||||
img.setDotsPerMeterY(qRound(header.YDpi / 25.4 * 1000));
|
img.setDotsPerMeterY(qRound(header.YDpi / 25.4 * 1000));
|
||||||
*outImage = img;
|
*outImage = std::move(img);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ bool SoftimagePICHandler::read(QImage *image)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*image = img;
|
*image = std::move(img);
|
||||||
m_state = Ready;
|
m_state = Ready;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1326,7 +1326,7 @@ bool PSDHandler::read(QImage *image)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*image = img;
|
*image = std::move(img);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ bool RASHandler::read(QImage *outImage)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*outImage = img;
|
*outImage = std::move(img);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,7 +748,7 @@ bool RAWHandler::read(QImage *image)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*image = img;
|
*image = std::move(img);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,9 +678,9 @@ bool SGIImage::writeImage(const QImage &image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasAlpha && img.format() != QImage::Format_ARGB32) {
|
if (hasAlpha && img.format() != QImage::Format_ARGB32) {
|
||||||
img = img.convertToFormat(QImage::Format_ARGB32);
|
img.convertTo(QImage::Format_ARGB32);
|
||||||
} else if (!hasAlpha && img.format() != QImage::Format_RGB32) {
|
} else if (!hasAlpha && img.format() != QImage::Format_RGB32) {
|
||||||
img = img.convertToFormat(QImage::Format_RGB32);
|
img.convertTo(QImage::Format_RGB32);
|
||||||
}
|
}
|
||||||
if (img.isNull()) {
|
if (img.isNull()) {
|
||||||
// qDebug() << "can't convert image to depth 32";
|
// qDebug() << "can't convert image to depth 32";
|
||||||
|
@ -419,7 +419,7 @@ bool TGAHandler::read(QImage *outImage)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*outImage = img;
|
*outImage = std::move(img);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ int main(int argc, char **argv)
|
|||||||
QTextStream(stderr) << "Unknown QImage data format " << parser.value(qimgformat) << '\n';
|
QTextStream(stderr) << "Unknown QImage data format " << parser.value(qimgformat) << '\n';
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
img = img.convertToFormat(qformat);
|
img.convertTo(qformat);
|
||||||
}
|
}
|
||||||
qint64 written = output.write(reinterpret_cast<const char *>(img.bits()), img.sizeInBytes());
|
qint64 written = output.write(reinterpret_cast<const char *>(img.bits()), img.sizeInBytes());
|
||||||
if (written != img.sizeInBytes()) {
|
if (written != img.sizeInBytes()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user