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

« back to all changes in this revision

Viewing changes to lib/exiv2imageloader.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 2007 Aurélien Gâteau <agateau@kde.org>
33
33
 
34
34
// Local
35
35
 
36
 
namespace Gwenview {
37
 
 
 
36
namespace Gwenview
 
37
{
38
38
 
39
39
struct Exiv2ImageLoaderPrivate {
40
 
        Exiv2::Image::AutoPtr mImage;
41
 
        QString mErrorMessage;
 
40
    Exiv2::Image::AutoPtr mImage;
 
41
    QString mErrorMessage;
42
42
};
43
43
 
44
 
 
45
44
Exiv2ImageLoader::Exiv2ImageLoader()
46
 
: d(new Exiv2ImageLoaderPrivate) {
47
 
}
48
 
 
49
 
 
50
 
Exiv2ImageLoader::~Exiv2ImageLoader() {
51
 
        delete d;
52
 
}
53
 
 
54
 
 
55
 
bool Exiv2ImageLoader::load(const QByteArray& data) {
56
 
        try {
57
 
                d->mImage = Exiv2::ImageFactory::open((unsigned char*)data.constData(), data.size());
58
 
                d->mImage->readMetadata();
 
45
: d(new Exiv2ImageLoaderPrivate)
 
46
{
 
47
}
 
48
 
 
49
Exiv2ImageLoader::~Exiv2ImageLoader()
 
50
{
 
51
    delete d;
 
52
}
 
53
 
 
54
bool Exiv2ImageLoader::load(const QByteArray& data)
 
55
{
 
56
    try {
 
57
        d->mImage = Exiv2::ImageFactory::open((unsigned char*)data.constData(), data.size());
 
58
        d->mImage->readMetadata();
59
59
#if EXIV2_VERSION >= EXIV2_MAKE_VERSION(0, 14, 0)
60
 
        // For some unknown reason, trying to catch Exiv2::Error fails with Exiv2
61
 
        // >=0.14. For now, just catch std::exception. I would welcome any
62
 
        // explanation.
63
 
        } catch (const std::exception& error) {
64
 
                d->mErrorMessage = error.what();
 
60
        // For some unknown reason, trying to catch Exiv2::Error fails with Exiv2
 
61
        // >=0.14. For now, just catch std::exception. I would welcome any
 
62
        // explanation.
 
63
    } catch (const std::exception& error) {
 
64
        d->mErrorMessage = error.what();
65
65
#else
66
 
        // In libexiv2 0.12, Exiv2::Error::what() returns an std::string.
67
 
        } catch (const Exiv2::Error& error) {
68
 
                d->mErrorMessage = error.what().c_str();
 
66
        // In libexiv2 0.12, Exiv2::Error::what() returns an std::string.
 
67
    } catch (const Exiv2::Error& error) {
 
68
        d->mErrorMessage = error.what().c_str();
69
69
#endif
70
 
                return false;
71
 
        }
72
 
        return true;
73
 
}
74
 
 
75
 
 
76
 
QString Exiv2ImageLoader::errorMessage() const {
77
 
        return d->mErrorMessage;
78
 
}
79
 
 
80
 
 
81
 
Exiv2::Image::AutoPtr Exiv2ImageLoader::popImage() {
82
 
        return d->mImage;
83
 
}
84
 
 
 
70
        return false;
 
71
    }
 
72
    return true;
 
73
}
 
74
 
 
75
QString Exiv2ImageLoader::errorMessage() const
 
76
{
 
77
    return d->mErrorMessage;
 
78
}
 
79
 
 
80
Exiv2::Image::AutoPtr Exiv2ImageLoader::popImage()
 
81
{
 
82
    return d->mImage;
 
83
}
85
84
 
86
85
} // namespace