windowsimagecreator.cpp 1.42 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
    windowsimagecreator.cpp - Thumbnail Creator for Microsoft Windows Images

    Copyright (c) 2009 by Pali Rohár <pali.rohar@gmail.com>

    *************************************************************************
    *                                                                       *
    * This library is free software; you can redistribute it and/or         *
    * modify it under the terms of the GNU General Public                   *
    * License as published by the Free Software Foundation; either          *
    * version 2 of the License, or (at your option) any later version.      *
    *                                                                       *
    *************************************************************************
*/

#include "windowsimagecreator.h"
#include "icoutils.h"

#include <QString>
#include <QImage>
21
22
#include <QImageReader>
#include <QMimeDatabase>
23
24
25

extern "C"
{
26
    Q_DECL_EXPORT ThumbCreator *new_creator()
27
28
29
    {
        return new WindowsImageCreator;
    }
30
31
}

32
33
bool WindowsImageCreator::create(const QString &path, int width, int height, QImage &img)
{
34
35
36
37
38
39
40
41
42
    if (IcoUtils::loadIcoImage(path, img, width, height)) {
        return true;
    }

    // Maybe it's an animated cursor
    if (QMimeDatabase().mimeTypeForFile(path).name() == QLatin1String("application/x-navi-animation")) {
        QImageReader reader(path, "ani");
        return reader.read(&img);
    }
43

44
    return false;
45
46

}