imagecreator.cpp 813 Bytes
Newer Older
Malte Starostik's avatar
Malte Starostik committed
1
/*  This file is part of the KDE libraries
2
3
    SPDX-FileCopyrightText: 2000 Carsten Pfeiffer <pfeiffer@kde.org>
    SPDX-FileCopyrightText: 2000 Malte Starostik <malte@kde.org>
Malte Starostik's avatar
Malte Starostik committed
4

5
    SPDX-License-Identifier: LGPL-2.0-or-later
Malte Starostik's avatar
Malte Starostik committed
6
7
*/

8
9
#include "imagecreator.h"

10
11
#include "macros.h"

12
#include <QImageReader>
Malte Starostik's avatar
Malte Starostik committed
13

14
EXPORT_THUMBNAILER_WITH_JSON(ImageCreator, "imagethumbnail.json")
15

16
bool ImageCreator::create(const QString &path, int, int, QImage &img)
Malte Starostik's avatar
Malte Starostik committed
17
18
{
    // create image preview
19
    QImageReader ir(path);
20
    ir.setAutoTransform(true);
21
22
23
    ir.setDecideFormatFromContent(true);
    img = ir.read();
    if (img.isNull())
24
        return false;
25
    if (img.depth() != 32)
26
        img = img.convertToFormat(img.hasAlphaChannel() ? QImage::Format_ARGB32 : QImage::Format_RGB32);
27
    return true;
Malte Starostik's avatar
Malte Starostik committed
28
}
29
30

#include "imagecreator.moc"