~ubuntu-branches/ubuntu/precise/gwenview/precise-proposed

« back to all changes in this revision

Viewing changes to lib/imageformats/jpegplugin.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:54 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20111215141754-z043hyx69dulbggf
Tags: upstream-4.7.90
Import upstream version 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// vim: set tabstop=4 shiftwidth=4 noexpandtab:
 
1
// vim: set tabstop=4 shiftwidth=4 expandtab:
2
2
/*
3
3
Gwenview: an image viewer
4
4
Copyright 2008 Aurélien Gâteau <agateau@kde.org>
29
29
// Local
30
30
#include "jpeghandler.h"
31
31
 
32
 
namespace Gwenview {
33
 
 
34
 
 
35
 
QStringList JpegPlugin::keys() const {
36
 
        return QStringList() << QLatin1String("jpeg") << QLatin1String("jpg");
37
 
}
38
 
 
39
 
 
40
 
QImageIOPlugin::Capabilities JpegPlugin::capabilities(QIODevice *device, const QByteArray &format) const {
41
 
        if (format == "jpeg" || format == "jpg") {
42
 
                return Capabilities(CanRead | CanWrite);
43
 
        }
44
 
        if (!format.isEmpty()) {
45
 
                return 0;
46
 
        }
47
 
        if (!device->isOpen()) {
48
 
                return 0;
49
 
        }
50
 
 
51
 
        Capabilities cap;
52
 
        if (device->isReadable() && JpegHandler::canRead(device)) {
53
 
                cap |= CanRead;
54
 
        }
55
 
        if (device->isWritable()) {
56
 
                cap |= CanWrite;
57
 
        }
58
 
        return cap;
59
 
}
60
 
 
61
 
QImageIOHandler *JpegPlugin::create(QIODevice *device, const QByteArray &format) const {
62
 
        QImageIOHandler *handler = new JpegHandler;
63
 
        handler->setDevice(device);
64
 
        handler->setFormat(format);
65
 
        return handler;
 
32
namespace Gwenview
 
33
{
 
34
 
 
35
QStringList JpegPlugin::keys() const
 
36
{
 
37
    return QStringList() << QLatin1String("jpeg") << QLatin1String("jpg");
 
38
}
 
39
 
 
40
QImageIOPlugin::Capabilities JpegPlugin::capabilities(QIODevice *device, const QByteArray &format) const
 
41
{
 
42
    if (format == "jpeg" || format == "jpg") {
 
43
        return Capabilities(CanRead | CanWrite);
 
44
    }
 
45
    if (!format.isEmpty()) {
 
46
        return 0;
 
47
    }
 
48
    if (!device->isOpen()) {
 
49
        return 0;
 
50
    }
 
51
 
 
52
    Capabilities cap;
 
53
    if (device->isReadable() && JpegHandler::canRead(device)) {
 
54
        cap |= CanRead;
 
55
    }
 
56
    if (device->isWritable()) {
 
57
        cap |= CanWrite;
 
58
    }
 
59
    return cap;
 
60
}
 
61
 
 
62
QImageIOHandler *JpegPlugin::create(QIODevice *device, const QByteArray &format) const
 
63
{
 
64
    QImageIOHandler *handler = new JpegHandler;
 
65
    handler->setDevice(device);
 
66
    handler->setFormat(format);
 
67
    return handler;
66
68
}
67
69
 
68
70
Q_EXPORT_STATIC_PLUGIN(JpegPlugin)
69
71
 
70
 
 
71
72
} // namespace