Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QImageIOHandler Class Reference
[QtGui module]

The QImageIOHandler class defines the common image I/O interface for all image formats in Qt. More...

#include <QImageIOHandler>

Public Types

  • enum ImageOption { Size, ClipRect, ScaledSize, ScaledClipRect, ..., Endianness }

Public Functions


Detailed Description

The QImageIOHandler class defines the common image I/O interface for all image formats in Qt.

Qt uses QImageIOHandler for reading and writing images through QImageReader and QImageWriter. You can also derive from this class to write your own image format handler using Qt's plugin mechanism.

Call setDevice() to assign a device to the handler, and setFormat() to assign a format to it. One QImageIOHandler may support more than one image format. canRead() returns true if an image can be read from the device, and read() and write() return true if reading or writing an image was completed successfully.

QImageIOHandler also has support for animations formats, through the functions loopCount(), imageCount(), nextImageDelay() and currentImageNumber().

In order to determine what options an image handler supports, Qt will call supportsOption() and setOption(). Make sure to reimplement these functions if you can provide support for any of the options in the ImageOption enum.

To write your own image handler, you must at least reimplement name(), canRead() and read(). Then create a QImageIOPlugin that can create the handler. Finally, install your plugin, and QImageReader and QImageWriter will then automatically load the plugin, and start using it.

See also QImageIOPlugin, QImageReader, and QImageWriter.


Member Type Documentation

enum QImageIOHandler::ImageOption

This enum describes the different options supported by QImageIOHandler. Some options are used to query an image for properties, and others are used to toggle the way in which an image should be written.

ConstantValueDescription
QImageIOHandler::Size0The original size of an image. A handler that supports this option is expected to read the size of the image from the image metadata, and return this size from option() as a QSize.
QImageIOHandler::ClipRect1The clip rect, or ROI (Region Of Interest). A handler that supports this option is expected to only read the provided QRect area from the original image in read(), before any other transformation is applied.
QImageIOHandler::ScaledSize4The scaled size of the image. A handler that supports this option is expected to scale the image to the provided size (a QSize), after applying any clip rect transformation (ClipRect). If the handler does not support this option, QImageReader will perform the scaling after the image has been read.
QImageIOHandler::ScaledClipRect3The scaled clip rect (or ROI, Region Of Interest) of the image. A handler that supports this option is expected to apply the provided clip rect (a QRect), after applying any scaling (ScaleSize) or regular clipping (ClipRect). If the handler does not support this option, QImageReader will apply the scaled clip rect after the image has been read.
QImageIOHandler::Description2The image description. A handler that supports this option is expected to read the description from the image metadata and return this as a QString, or when writing an image it is expected to store the description in the image metadata.
QImageIOHandler::CompressionRatio5The compression ratio of the image data. A handler that supports this option is expected to set its compression rate depending on the value of this option (an int) when writing.
QImageIOHandler::Gamma6The gamma level of the image. A handler that supports this option is expected to set the image gamma level depending on the value of this option (a float) when writing.
QImageIOHandler::Quality7The quality level of the image. A handler that supports this option is expected to set the image quality level depending on the value of this option (an int) when writing.
QImageIOHandler::Name8The name of the image. A handler that supports this option is expected to read the name from the image metadata and return this as a QString, or when writing an image it is expected to store the name in the image metadata.
QImageIOHandler::SubType9The subtype of the image. A handler that supports this option can use the subtype value to help when reading and writing images. For example, a PPM handler may have a subtype value of "ppm" or "ppmraw".
QImageIOHandler::IncrementalReading10A handler that supports this option is expected to read the image in several passes, as if it was an animation. QImageReader will treat the image as an animation.
QImageIOHandler::Endianness11The endianness of the image. Certain image formats can be stored as BigEndian or LittleEndian. A handler that supports Endianness uses the value of this option to determine how the image should be stored.

Member Function Documentation

QImageIOHandler::QImageIOHandler ()

Constructs a QImageIOHandler object.

QImageIOHandler::~QImageIOHandler ()   [virtual]

Destructs the QImageIOHandler object.

bool QImageIOHandler::canRead () const   [pure virtual]

Returns true if an image can be read from the device (i.e., the image format is supported, the device can be read from and the initial header information suggests that the image can be read); otherwise returns false.

See also read().

int QImageIOHandler::currentImageNumber () const   [virtual]

For image formats that support animation, this function returns the sequence number of the current image in the animation. If the image format does not support animation, or if it is unable to determine the current sequence number, 0 is returned.

QRect QImageIOHandler::currentImageRect () const   [virtual]

Returns the rect of the current image. If no rect is defined for the image, and empty QRect() is returned.

This function is useful for animations, where only parts of the frame may be updated at a time.

QIODevice * QImageIOHandler::device () const

Returns the device currently assigned to the QImageIOHandler. If not device has been assigned, 0 is returned.

See also setDevice().

QByteArray QImageIOHandler::format () const

Returns the format that is currently assigned to QImageIOHandler. If no format has been assigned, an empty string is returned.

See also setFormat().

int QImageIOHandler::imageCount () const   [virtual]

For image formats that support animation, this function returns the number of images in the animation. If the image format does not support animation, or if it is unable to determine the number of images, 0 is returned.

The default implementation returns 1 if canRead() returns true; otherwise 0 is returned.

bool QImageIOHandler::jumpToImage ( int imageNumber )   [virtual]

For image formats that support animation, this function jumps to the image whose sequence number is imageNumber. The next call to read() will attempt to read this image.

The default implementation does nothing, and returns false.

bool QImageIOHandler::jumpToNextImage ()   [virtual]

For image formats that support animation, this function jumps to the next image.

The default implementation does nothing, and returns false.

int QImageIOHandler::loopCount () const   [virtual]

For image formats that support animation, this function returns the number of times the animation should loop. If the image format does not support animation, 0 is returned.

QByteArray QImageIOHandler::name () const   [pure virtual]

Returns the name of the image handler. For handlers that support only one image format, this should be common identifier of that format. For example, a JPEG handler should return "jpeg", and a TIFF handler should return "tiff". The name should be returned in lowercase; otherwise Qt will convert it to lowercase.

int QImageIOHandler::nextImageDelay () const   [virtual]

For image formats that support animation, this function returns the number of milliseconds to wait until reading the next image. If the image format does not support animation, 0 is returned.

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

Returns the value assigned to option as a QVariant. The type of the value depends on the option. For example, option(Size) returns a QSize variant.

See also setOption() and supportsOption().

bool QImageIOHandler::read ( QImage * image )   [pure virtual]

Read an image from the device, and stores it in image. For image formats that support incremental loading, and for animation formats, the image handler can assume that image points to the previous frame.

See also canRead().

void QImageIOHandler::setDevice ( QIODevice * device )

Sets the device of the QImageIOHandler to device. The image handler will use this device when reading and writing images.

See also device().

void QImageIOHandler::setFormat ( const QByteArray & format )

Sets the format of the QImageIOHandler to format. The format is most useful for handlers that support multiple image formats.

See also format().

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

Sets the option option with the value value.

See also option() and ImageOption.

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

Returns true if the QImageIOHandler supports the option option; otherwise returns false. For example, if the QImageIOHandler supports the Size option, supportsOption(Size) must return true.

See also setOption() and option().

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

Writes the image image to the assigned device. Returns true on success; otherwise returns false.

The default implementation does nothing, and simply returns false.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 85
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 19
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.0
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web