Skip to content
Snippets Groups Projects
Commit 95b6cf26 authored by Jake Petroules's avatar Jake Petroules Committed by The Qt Project
Browse files

Add JPEG 2000 plugin.


It is moving from Qt Solutions.

Change-Id: Ie0dc44d258597f871544fa43238528f42628b799
Reviewed-by: default avatarJake Petroules <jake.petroules@petroules.com>
Reviewed-by: default avatarShawn Rutledge <shawn.rutledge@digia.com>
parent 5c4036ee
No related merge requests found
Showing
with 1533 additions and 6 deletions
...@@ -21,3 +21,4 @@ information about a particular change. ...@@ -21,3 +21,4 @@ information about a particular change.
- Add read/write support for Direct Draw Surface images. - Add read/write support for Direct Draw Surface images.
- Add read/write support for ICNS images. - Add read/write support for ICNS images.
- Add read/write support for JPEG 2000 images.
...@@ -15,7 +15,7 @@ exampledirs += ../examples ...@@ -15,7 +15,7 @@ exampledirs += ../examples
HTML.nobreadcrumbs = "true" HTML.nobreadcrumbs = "true"
examples.fileextensions = "*.cpp *.h *.js *.svg *.xml *.ui *.qml" examples.fileextensions = "*.cpp *.h *.js *.svg *.xml *.ui *.qml"
examples.imageextensions = "*.png *.jpeg *.jpg *.gif *.mng" examples.imageextensions = "*.png *.jp2 *.jpeg *.jpg *.gif *.mng"
headers.fileextensions = "*.h *.ch *.h++ *.hh *.hpp *.hxx" headers.fileextensions = "*.h *.ch *.h++ *.hh *.hpp *.hxx"
sources.fileextensions = "*.cpp *.qdoc *.mm *.qml" sources.fileextensions = "*.cpp *.qdoc *.mm *.qml"
...@@ -54,6 +54,7 @@ libraries. If not found, it may fall back on using a bundled copy (in ...@@ -54,6 +54,7 @@ libraries. If not found, it may fall back on using a bundled copy (in
\header \li Format \li Description \li Support \li 3rd party codec \header \li Format \li Description \li Support \li 3rd party codec
\row \li DDS \li Direct Draw Surface \li Read/write \li No \row \li DDS \li Direct Draw Surface \li Read/write \li No
\row \li ICNS \li Apple Icon Image \li Read/write \li No \row \li ICNS \li Apple Icon Image \li Read/write \li No
\row \li JP2 \li Joint Photographic Experts Group 2000 \li Read/write \li Yes (bundled)
\row \li MNG \li Multiple-image Network Graphics \li Read \li Yes (bundled) \row \li MNG \li Multiple-image Network Graphics \li Read \li Yes (bundled)
\row \li TGA \li Truevision Graphics Adapter \li Read \li No \row \li TGA \li Truevision Graphics Adapter \li Read \li No
\row \li TIFF \li Tagged Image File Format \li Read/write \li Yes (bundled) \row \li TIFF \li Tagged Image File Format \li Read/write \li Yes (bundled)
......
TEMPLATE = subdirs TEMPLATE = subdirs
SUBDIRS = \ SUBDIRS = \
tga \ dds \
wbmp \ icns \
jp2 \
mng \ mng \
tga \
tiff \ tiff \
dds \ wbmp
icns
wince:SUBDIRS -= jp2
winrt { winrt {
SUBDIRS -= tiff \ SUBDIRS -= tiff \
......
{
"Keys": [ "jp2" ],
"MimeTypes": [ "image/jp2", "image/jpx", "image/jpm", "video/mj2" ]
}
TARGET = qjp2
PLUGIN_TYPE = imageformats
PLUGIN_CLASS_NAME = QJp2Plugin
load(qt_plugin)
include(qjp2handler.pri)
SOURCES += main.cpp
OTHER_FILES += jp2.json
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2014 Petroules Corporation.
** Contact: http://www.qt-project.org/legal
**
** This file is part of the JP2 plugins in the Qt ImageFormats module.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <qimageiohandler.h>
#include <qstringlist.h>
#ifndef QT_NO_IMAGEFORMATPLUGIN
#include "qjp2handler_p.h"
#include <qiodevice.h>
#include <qbytearray.h>
QT_BEGIN_NAMESPACE
class QJp2Plugin : public QImageIOPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "jp2.json")
public:
QStringList keys() const;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
};
QStringList QJp2Plugin::keys() const
{
return QStringList() << QLatin1String("jp2") << QLatin1String("j2k");
}
QImageIOPlugin::Capabilities QJp2Plugin::capabilities(QIODevice *device, const QByteArray &format) const
{
if (format == "jp2" || format == "j2k")
return Capabilities(CanRead | CanWrite);
if (!format.isEmpty())
return 0;
if (!device->isOpen())
return 0;
Capabilities cap;
if (device->isReadable() && QJp2Handler::canRead(device, 0))
cap |= CanRead;
if (device->isWritable())
cap |= CanWrite;
return cap;
}
QImageIOHandler *QJp2Plugin::create(QIODevice *device, const QByteArray &format) const
{
QJp2Handler *handler = new QJp2Handler();
handler->setDevice(device);
handler->setFormat(format);
return handler;
}
QT_END_NAMESPACE
#include "main.moc"
#endif // !QT_NO_IMAGEFORMATPLUGIN
This diff is collapsed.
# common to plugin and built-in forms
INCLUDEPATH *= $$PWD
HEADERS += $$PWD/qjp2handler_p.h
SOURCES += $$PWD/qjp2handler.cpp
config_jasper {
msvc: LIBS += libjasper.lib
else: LIBS += -ljasper
} else {
include($$PWD/../../../3rdparty/jasper.pri)
}
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2014 Petroules Corporation.
** Contact: http://www.qt-project.org/legal
**
** This file is part of the JP2 plugins in the Qt ImageFormats module.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QJP2HANDLER_H
#define QJP2HANDLER_H
#include <QtCore/qscopedpointer.h>
#include <QtGui/qimageiohandler.h>
QT_BEGIN_NAMESPACE
class QImage;
class QByteArray;
class QIODevice;
class QVariant;
class QJp2HandlerPrivate;
class QJp2Handler : public QImageIOHandler
{
public:
QJp2Handler();
virtual ~QJp2Handler();
static bool canRead(QIODevice *iod, QByteArray *subType);
virtual bool canRead() const;
virtual bool read(QImage *image);
virtual bool write(const QImage &image);
virtual QVariant option(ImageOption option) const;
virtual void setOption(ImageOption option, const QVariant &value);
virtual bool supportsOption(ImageOption option) const;
virtual QByteArray name() const;
private:
Q_DECLARE_PRIVATE(QJp2Handler)
QScopedPointer<QJp2HandlerPrivate> d_ptr;
};
QT_END_NAMESPACE
#endif // QJP2HANDLER_P_H
...@@ -3,6 +3,7 @@ SUBDIRS = \ ...@@ -3,6 +3,7 @@ SUBDIRS = \
tga \ tga \
wbmp \ wbmp \
dds \ dds \
icns icns \
jp2
contains(QT_CONFIG, system-zlib): SUBDIRS += mng tiff contains(QT_CONFIG, system-zlib): SUBDIRS += mng tiff
TARGET = tst_qjp2
QT = core gui testlib
CONFIG -= app_bundle
CONFIG += testcase
SOURCES += tst_qjp2.cpp
RESOURCES += $$PWD/../../shared/images/jp2.qrc
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2014 Petroules Corporation.
** Contact: http://www.qt-project.org/legal
**
** This file is part of the MNG autotests in the Qt ImageFormats module.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtTest/QtTest>
#include <QtGui/QtGui>
class tst_qjp2: public QObject
{
Q_OBJECT
private slots:
void readImage_data();
void readImage();
};
void tst_qjp2::readImage_data()
{
QTest::addColumn<QString>("fileName");
QTest::addColumn<QString>("referenceFileName");
QTest::addColumn<QSize>("size");
QTest::newRow("logo") << QString("logo.jp2") << QString("logo.bmp") << QSize(498, 80);
}
void tst_qjp2::readImage()
{
QFETCH(QString, fileName);
QFETCH(QString, referenceFileName);
QFETCH(QSize, size);
QString path = QString(":/jp2/") + fileName;
QImageReader reader(path);
QVERIFY(reader.canRead());
QImage image = reader.read();
QVERIFY(!image.isNull());
QCOMPARE(image.size(), size);
path = QString(":jp2/") + referenceFileName;
QImageReader referenceReader(path);
QVERIFY(referenceReader.canRead());
QImage referenceImage = referenceReader.read();
QVERIFY(!referenceImage.isNull());
QCOMPARE(referenceImage.size(), size);
QCOMPARE(image, referenceImage);
}
QTEST_MAIN(tst_qjp2)
#include "tst_qjp2.moc"
<RCC>
<qresource prefix="/">
<file>jp2/logo.bmp</file>
<file>jp2/logo.jp2</file>
</qresource>
</RCC>
tests/shared/images/jp2/logo.bmp

117 KiB

File added
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment