Qt 4.8
Public Functions | Static Public Functions | Properties | List of all members
QTgaHandler Class Reference

#include <qtgahandler.h>

Inheritance diagram for QTgaHandler:
QImageIOHandler

Public Functions

bool canRead () const
 Returns true if an image can be read from the device (i. More...
 
QByteArray name () const
 Use format() instead. More...
 
QVariant option (ImageOption option) const
 Returns the value assigned to option as a QVariant. More...
 
 QTgaHandler ()
 
bool read (QImage *image)
 Read an image from the device, and stores it in image. More...
 
void setOption (ImageOption option, const QVariant &value)
 Sets the option option with the value value. More...
 
bool supportsOption (ImageOption option) const
 Returns true if the QImageIOHandler supports the option option; otherwise returns false. More...
 
 ~QTgaHandler ()
 
- Public Functions inherited from QImageIOHandler
virtual int currentImageNumber () const
 For image formats that support animation, this function returns the sequence number of the current image in the animation. More...
 
virtual QRect currentImageRect () const
 Returns the rect of the current image. More...
 
QIODevicedevice () const
 Returns the device currently assigned to the QImageIOHandler. More...
 
QByteArray format () const
 Returns the format that is currently assigned to QImageIOHandler. More...
 
virtual int imageCount () const
 For image formats that support animation, this function returns the number of images in the animation. More...
 
virtual bool jumpToImage (int imageNumber)
 For image formats that support animation, this function jumps to the image whose sequence number is imageNumber. More...
 
virtual bool jumpToNextImage ()
 For image formats that support animation, this function jumps to the next image. More...
 
virtual int loopCount () const
 For image formats that support animation, this function returns the number of times the animation should loop. More...
 
virtual int nextImageDelay () const
 For image formats that support animation, this function returns the number of milliseconds to wait until reading the next image. More...
 
 QImageIOHandler ()
 Constructs a QImageIOHandler object. More...
 
void setDevice (QIODevice *device)
 Sets the device of the QImageIOHandler to device. More...
 
void setFormat (const QByteArray &format)
 Sets the format of the QImageIOHandler to format. More...
 
void setFormat (const QByteArray &format) const
 Sets the format of the QImageIOHandler to format. More...
 
virtual bool write (const QImage &image)
 Writes the image image to the assigned device. More...
 
virtual ~QImageIOHandler ()
 Destructs the QImageIOHandler object. More...
 

Static Public Functions

static bool canRead (QIODevice *device)
 

Properties

QTgaFiletga
 

Additional Inherited Members

- Public Types inherited from QImageIOHandler
enum  ImageOption {
  Size, ClipRect, Description, ScaledClipRect,
  ScaledSize, CompressionRatio, Gamma, Quality,
  Name, SubType, IncrementalReading, Endianness,
  Animation, BackgroundColor, ImageFormat
}
 This enum describes the different options supported by QImageIOHandler. More...
 
- Protected Functions inherited from QImageIOHandler
 QImageIOHandler (QImageIOHandlerPrivate &dd)
 Constructs a QImageIOHandler object, using the private member dd. More...
 
- Protected Variables inherited from QImageIOHandler
QScopedPointer< QImageIOHandlerPrivated_ptr
 

Detailed Description

Definition at line 51 of file qtgahandler.h.

Constructors and Destructors

◆ QTgaHandler()

QTgaHandler::QTgaHandler ( )

Definition at line 51 of file qtgahandler.cpp.

52  : QImageIOHandler()
53  , tga(0)
54 {
55 }
QImageIOHandler()
Constructs a QImageIOHandler object.
QTgaFile * tga
Definition: qtgahandler.h:69

◆ ~QTgaHandler()

QTgaHandler::~QTgaHandler ( )

Definition at line 57 of file qtgahandler.cpp.

58 {
59  delete tga;
60 }
QTgaFile * tga
Definition: qtgahandler.h:69

Functions

◆ canRead() [1/2]

bool QTgaHandler::canRead ( ) const
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.

When reimplementing canRead(), make sure that the I/O device (device()) is left in its original state (e.g., by using peek() rather than read()).

See also
read(), QIODevice::peek()

Implements QImageIOHandler.

Definition at line 62 of file qtgahandler.cpp.

Referenced by QTgaPlugin::capabilities(), option(), and read().

63 {
64  if (!tga)
65  tga = new QTgaFile(device());
66  if (tga->isValid())
67  {
68  setFormat("tga");
69  return true;
70  }
71  return false;
72 }
void setFormat(const QByteArray &format)
Sets the format of the QImageIOHandler to format.
QTgaFile * tga
Definition: qtgahandler.h:69
QIODevice * device() const
Returns the device currently assigned to the QImageIOHandler.
bool isValid() const
Definition: qtgafile.h:104

◆ canRead() [2/2]

bool QTgaHandler::canRead ( QIODevice device)
static

Definition at line 74 of file qtgahandler.cpp.

75 {
76  if (!device) {
77  qWarning("QTgaHandler::canRead() called with no device");
78  return false;
79  }
80  QTgaFile tga(device);
81  return tga.isValid();
82 }
Q_CORE_EXPORT void qWarning(const char *,...)
QTgaFile * tga
Definition: qtgahandler.h:69
bool isValid() const
Definition: qtgafile.h:104

◆ name()

QByteArray QTgaHandler::name ( ) const
virtual

Use format() instead.

Reimplemented from QImageIOHandler.

Definition at line 92 of file qtgahandler.cpp.

93 {
94  return "tga";
95 }

◆ option()

QVariant QTgaHandler::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(), supportsOption()

Reimplemented from QImageIOHandler.

Definition at line 97 of file qtgahandler.cpp.

98 {
99  if (option == Size && canRead()) {
100  return tga->size();
101  } else if (option == CompressionRatio) {
102  return tga->compression();
103  } else if (option == ImageFormat) {
104  return QImage::Format_ARGB32;
105  }
106  return QVariant();
107 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
Compression compression() const
Definition: qtgafile.h:151
QVariant option(ImageOption option) const
Returns the value assigned to option as a QVariant.
Definition: qtgahandler.cpp:97
bool canRead() const
Returns true if an image can be read from the device (i.
Definition: qtgahandler.cpp:62
QTgaFile * tga
Definition: qtgahandler.h:69
QSize size() const
Definition: qtgafile.h:146

◆ read()

bool QTgaHandler::read ( QImage image)
virtual

Read an image from the device, and stores it in image.

Returns true if the image is successfully read; otherwise returns false.

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()

Implements QImageIOHandler.

Definition at line 84 of file qtgahandler.cpp.

85 {
86  if (!canRead())
87  return false;
88  *image = tga->readImage();
89  return !image->isNull();
90 }
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
QImage readImage()
Reads an image file from the QTgaFile&#39;s device, and returns it.
Definition: qtgafile.cpp:220
bool canRead() const
Returns true if an image can be read from the device (i.
Definition: qtgahandler.cpp:62
QTgaFile * tga
Definition: qtgahandler.h:69

◆ setOption()

void QTgaHandler::setOption ( ImageOption  option,
const QVariant value 
)
virtual

Sets the option option with the value value.

See also
option(), ImageOption

Reimplemented from QImageIOHandler.

Definition at line 109 of file qtgahandler.cpp.

110 {
111  Q_UNUSED(option);
112  Q_UNUSED(value);
113 }
QVariant option(ImageOption option) const
Returns the value assigned to option as a QVariant.
Definition: qtgahandler.cpp:97
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ supportsOption()

bool QTgaHandler::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(), option()

Reimplemented from QImageIOHandler.

Definition at line 115 of file qtgahandler.cpp.

116 {
117  return option == CompressionRatio
118  || option == Size
119  || option == ImageFormat;
120 }
QVariant option(ImageOption option) const
Returns the value assigned to option as a QVariant.
Definition: qtgahandler.cpp:97

Properties

◆ tga

QTgaFile* QTgaHandler::tga
mutableprivate

Definition at line 69 of file qtgahandler.h.

Referenced by canRead(), option(), read(), and ~QTgaHandler().


The documentation for this class was generated from the following files: