![]() |
Qt 6.x
The Qt SDK
|
#include <qtgafile.h>
Public Types | |
enum | Compression { NoCompression = 0 , RleCompression = 1 } |
enum | HeaderOffset { IdLength = 0 , ColorMapType = 1 , ImageType = 2 , CMapStart = 3 , CMapLength = 5 , CMapDepth = 7 , XOffset = 8 , YOffset = 10 , Width = 12 , Height = 14 , PixelDepth = 16 , ImageDescriptor = 17 , HeaderSize = 18 } |
enum | FooterOffset { ExtensionOffset = 0 , DeveloperOffset = 4 , SignatureOffset = 8 , FooterSize = 26 } |
Public Member Functions | |
QTgaFile (QIODevice *) | |
Construct a new QTgaFile object getting data from device. | |
~QTgaFile () | |
bool | isValid () const |
QString | errorMessage () const |
QImage | readImage () |
int | xOffset () const |
int | yOffset () const |
int | width () const |
int | height () const |
QSize | size () const |
Compression | compression () const |
File data container for a TrueVision Graphics format file.
Format is as described here: http://local.wasp.uwa.edu.au/~pbourke/dataformats/tga/ http://netghost.narod.ru/gff2/graphics/summary/tga.htm
Usage is:
The class is designed to handle sequential and non-sequential sources, so during construction the mHeader is read. Then during the readImage() call the rest of the data is read.
After passing myFile to the constructor, if the QIODevice *myFile is read, or has seek() called, the results are undefined - so don't do that.
Definition at line 15 of file qtgafile.h.
Enumerator | |
---|---|
NoCompression | |
RleCompression |
Definition at line 20 of file qtgafile.h.
Enumerator | |
---|---|
ExtensionOffset | |
DeveloperOffset | |
SignatureOffset | |
FooterSize |
Definition at line 41 of file qtgafile.h.
Enumerator | |
---|---|
IdLength | |
ColorMapType | |
ImageType | |
CMapStart | |
CMapLength | |
CMapDepth | |
XOffset | |
YOffset | |
Width | |
Height | |
PixelDepth | |
ImageDescriptor | |
HeaderSize |
Definition at line 25 of file qtgafile.h.
QTgaFile::QTgaFile | ( | QIODevice * | device | ) |
Construct a new QTgaFile object getting data from device.
The object does not take ownership of the device, but until the object is destroyed do not do any non-const operations, eg seek or read on the device.
Definition at line 97 of file qtgafile.cpp.
References bitsPerPixel(), device, FooterSize, HeaderSize, height(), ImageType, QIODevice::isReadable(), QIODevice::isSequential(), PixelDepth, QIODevice::pos(), qstrncmp(), QIODevice::read(), QIODevice::seek(), SignatureOffset, QIODevice::size(), tr, and width().
QTgaFile::~QTgaFile | ( | ) |
Destroy the device, recovering any resources.
Definition at line 163 of file qtgafile.cpp.
|
inline |
Definition at line 113 of file qtgafile.h.
References NoCompression.
Referenced by QTgaHandler::option().
|
inline |
Definition at line 74 of file qtgafile.h.
Referenced by QTgaHandler::canRead().
|
inline |
Definition at line 103 of file qtgafile.h.
References Height.
Referenced by QTgaFile(), readImage(), and size().
|
inline |
Definition at line 69 of file qtgafile.h.
References QString::isEmpty().
Referenced by QTgaHandler::canRead(), QTgaHandler::canRead(), and readImage().
QImage QTgaFile::readImage | ( | ) |
Reads an image file from the QTgaFile's device, and returns it.
This method seeks to the absolute position of the image data in the file, so no assumptions are made about where the devices read pointer is when this method is called. For this reason only random access devices are supported.
If the constructor completed successfully, such that isValid() returns true, then this method is likely to succeed, unless the file is somehow corrupted.
In the case that the read fails, the QImage returned will be null, such that QImage::isNull() will be true.
Definition at line 181 of file qtgafile.cpp.
References QImageIOHandler::allocateImage(), bitsPerPixel(), CMapDepth, CMapLength, ColorMapType, desc, QImage::Format_ARGB32, QIODevice::getChar(), HeaderSize, height(), i, IdLength, ImageDescriptor, isValid(), PixelDepth, read(), QIODevice::seek(), QImage::setPixel(), tr, and width().
Referenced by QTgaHandler::read().
|
inline |
Definition at line 108 of file qtgafile.h.
References height(), and width().
Referenced by QTgaHandler::option().
|
inline |
Definition at line 98 of file qtgafile.h.
References Width.
Referenced by QTgaFile(), readImage(), and size().
|
inline |
Definition at line 88 of file qtgafile.h.
References XOffset.
|
inline |
Definition at line 93 of file qtgafile.h.
References YOffset.