mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
knotify: image conversion optimization
QImage::scanLine() detaches the image, QImage::constScanLine() does not Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
54ff6f125c
commit
61d831381a
1 changed files with 3 additions and 3 deletions
|
@ -64,7 +64,7 @@ QVariant variantForImage(const QImage &_image)
|
|||
{
|
||||
qDBusRegisterMetaType<SpecImage>();
|
||||
|
||||
QImage image = _image.convertToFormat(QImage::Format_ARGB32);
|
||||
const QImage image = _image.convertToFormat(QImage::Format_ARGB32);
|
||||
|
||||
int rowStride = image.width() * 4;
|
||||
|
||||
|
@ -78,8 +78,8 @@ QVariant variantForImage(const QImage &_image)
|
|||
data.resize(rowStride * image.height());
|
||||
char* dst = data.data();
|
||||
for (int y=0; y<image.height(); ++y) {
|
||||
QRgb* src = (QRgb*)image.scanLine(y);
|
||||
QRgb* end = src + image.width();
|
||||
const QRgb* src = (const QRgb*)image.constScanLine(y);
|
||||
const QRgb* end = src + image.width();
|
||||
for (;src != end; ++src) {
|
||||
// Probably slow, but free of endianess issues
|
||||
*dst++ = qRed(*src);
|
||||
|
|
Loading…
Add table
Reference in a new issue