Home

QtJP2ImageHandler Class Reference

The QtJP2ImageHandler class provides support for reading and writing JPEG 2000 image files with Qts plugin system. Currently, it only supports dynamically-loaded plugins. More...

 #include <QtJP2ImageHandler>

Inherits QImageIOHandler.


Public Functions

QtJP2ImageHandler ( QIODevice * device )
virtual ~QtJP2ImageHandler ()

Reimplemented Public Functions

virtual bool canRead () const
virtual QByteArray name () const
virtual QVariant option ( ImageOption option ) const
virtual bool read ( QImage * image )
virtual void setOption ( ImageOption option, const QVariant & value )
virtual bool supportsOption ( ImageOption option ) const
virtual bool write ( const QImage & image )

Static Public Members

bool canRead ( QIODevice * iod, QByteArray * subType )

Additional Inherited Members


Detailed Description

The QtJP2ImageHandler class provides support for reading and writing JPEG 2000 image files with Qts plugin system. Currently, it only supports dynamically-loaded plugins.

JPEG files comes in two subtypes: the JPEG 2000 file format (.jp2) and the JPEG 2000 code stream format (.j2k, .jpc, or .j2c). QtJP2ImageHandler can read and write both types.

To select a subtype, use the setOption() function with the QImageIOHandler::SubType option and a parameter value of "jp2" or "j2k".

To set the image quality when writing, you can use setOption() with the QImageIOHandler::Quality option, or QImageWriter::setQuality() if your are using a QImageWriter object to write the image. The Image quality is specified as an int in the range 0 to 100. 0 means maximum compression and 99 means minimum compression. 100 selects lossless encoding, and this is the default value.

The JPEG handler is only available as a plugin, and this enables you to use normal QImage and QPixmap functions to read and write images. For example:

 myLabel->setPixmap(QPixmap("myimage.jp2"));

 QPixmap myPixmap;
 myPixmap.save("myimage.jp2", "JP2");

Member Function Documentation

QtJP2ImageHandler::QtJP2ImageHandler ( QIODevice * device )

Constructs an instance of QtJP2ImageHandler initialized to use device.

QtJP2ImageHandler::~QtJP2ImageHandler ()   [virtual]

Desctructor for QtJP2ImageHandler.

bool QtJP2ImageHandler::canRead ( QIODevice * iod, QByteArray * subType )   [static]

Verifies if some values (magic bytes) are set as expected in the header of the file. If the magic bytes were found, we assume that we can read the file. The function will assume that the iod is pointing to the beginning of the JPEG 2000 header. (i.e. it will for instance not seek to the beginning of a file before reading).

If subType is not 0, it will contain "jp2" or "j2k" upon successful return.

bool QtJP2ImageHandler::canRead () const   [virtual]

Reimplemented from QImageIOHandler::canRead().

QByteArray QtJP2ImageHandler::name () const   [virtual]

Reimplemented from QImageIOHandler::name().

Return the common identifier of the format. For JPEG 2000 this will return "jp2".

QVariant QtJP2ImageHandler::option ( ImageOption option ) const   [virtual]

Reimplemented from QImageIOHandler::option().

Get the value associated with option.

See also setOption().

bool QtJP2ImageHandler::read ( QImage * image )   [virtual]

Reimplemented from QImageIOHandler::read().

void QtJP2ImageHandler::setOption ( ImageOption option, const QVariant & value )   [virtual]

Reimplemented from QImageIOHandler::setOption().

The JPEG 2000 handler supports two options. Set option to QImageIOHandler::Quality to balance between quality and the compression level, where value should be an integer in the interval [0-100]. 0 is maximum compression (low quality) and 100 is lossless compression (high quality).

Set option to QImageIOHandler::Subtype to choose the subtype, where value should be a string equal to either "jp2" or "j2k"

See also option().

bool QtJP2ImageHandler::supportsOption ( ImageOption option ) const   [virtual]

Reimplemented from QImageIOHandler::supportsOption().

This function will return true if option is set to either QImageIOHandler::Quality or QImageIOHandler::Subtype.

bool QtJP2ImageHandler::write ( const QImage & image )   [virtual]

Reimplemented from QImageIOHandler::write().


Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions