~jpakkane/thumbnailer/standalone-albumart

« back to all changes in this revision

Viewing changes to plugins/Ubuntu/Thumbnailer/artgeneratorcommon.cpp

  • Committer: Jussi Pakkanen
  • Date: 2013-09-25 12:45:32 UTC
  • Revision ID: jussi.pakkanen@canonical.com-20130925124532-spx31kdvxwizl34a
Added Debian packaging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2014 Canonical Ltd.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU Lesser General Public License as published by
6
 
 * the Free Software Foundation; version 3.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
 
 * GNU Lesser General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU Lesser General Public License
14
 
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 * Authors: Jussi Pakkanen <jussi.pakkanen@canonical.com>
17
 
 *          James Henstridge <james.henstridge@canonical.com>
18
 
 *          Pawel Stolowski <pawel.stolowski@canonical.com>
19
 
*/
20
 
 
21
 
#include "artgeneratorcommon.h"
22
 
#include <QFile>
23
 
 
24
 
QString sizeToDesiredSizeString(const QSize& requestedSize)
25
 
{
26
 
    QString desiredSize = "original";
27
 
    int size = requestedSize.width() > requestedSize.height() ? requestedSize.width() : requestedSize.height();
28
 
    if (size < 128) {
29
 
        desiredSize = "small";
30
 
    } else if (size < 256) {
31
 
        desiredSize = "large";
32
 
    } else if (size < 512) {
33
 
        desiredSize = "xlarge";
34
 
    }
35
 
    return desiredSize;
36
 
}
37
 
 
38
 
QImage imageFromFd(int fd, QSize *realSize)
39
 
{
40
 
    QFile file;
41
 
    file.open(fd, QIODevice::ReadOnly);
42
 
    QImage image;
43
 
    image.load(&file, NULL);
44
 
    *realSize = image.size();
45
 
    return image;
46
 
}