Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QTgaFile Class Reference

#include <qtgafile.h>

+ Collaboration diagram for QTgaFile:

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
 

Detailed Description

Since
4.8

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:

QTgaFile tga(myFile);
QImage tgaImage;
if (tga.isValid())
tgaImage = tga.readImage();
\inmodule QtGui
Definition qimage.h:37

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.

Member Enumeration Documentation

◆ Compression

Enumerator
NoCompression 
RleCompression 

Definition at line 20 of file qtgafile.h.

◆ FooterOffset

Enumerator
ExtensionOffset 
DeveloperOffset 
SignatureOffset 
FooterSize 

Definition at line 41 of file qtgafile.h.

◆ HeaderOffset

Enumerator
IdLength 
ColorMapType 
ImageType 
CMapStart 
CMapLength 
CMapDepth 
XOffset 
YOffset 
Width 
Height 
PixelDepth 
ImageDescriptor 
HeaderSize 

Definition at line 25 of file qtgafile.h.

Constructor & Destructor Documentation

◆ QTgaFile()

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

+ Here is the call graph for this function:

◆ ~QTgaFile()

QTgaFile::~QTgaFile ( )

Destroy the device, recovering any resources.

Definition at line 163 of file qtgafile.cpp.

Member Function Documentation

◆ compression()

QTgaFile::Compression QTgaFile::compression ( ) const
inline

Definition at line 113 of file qtgafile.h.

References NoCompression.

Referenced by QTgaHandler::option().

+ Here is the caller graph for this function:

◆ errorMessage()

QString QTgaFile::errorMessage ( ) const
inline

Definition at line 74 of file qtgafile.h.

Referenced by QTgaHandler::canRead().

+ Here is the caller graph for this function:

◆ height()

int QTgaFile::height ( ) const
inline

Definition at line 103 of file qtgafile.h.

References Height.

Referenced by QTgaFile(), readImage(), and size().

+ Here is the caller graph for this function:

◆ isValid()

bool QTgaFile::isValid ( ) const
inline

Definition at line 69 of file qtgafile.h.

References QString::isEmpty().

Referenced by QTgaHandler::canRead(), QTgaHandler::canRead(), and readImage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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, QImage::Format_ARGB32, QIODevice::getChar(), HeaderSize, height(), i, IdLength, ImageDescriptor, isValid(), PixelDepth, read(), QIODevice::seek(), QImage::setPixel(), tr, and width().

Referenced by QTgaHandler::read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

QSize QTgaFile::size ( ) const
inline

Definition at line 108 of file qtgafile.h.

References height(), and width().

Referenced by QTgaHandler::option().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ width()

int QTgaFile::width ( ) const
inline

Definition at line 98 of file qtgafile.h.

References Width.

Referenced by QTgaFile(), readImage(), and size().

+ Here is the caller graph for this function:

◆ xOffset()

int QTgaFile::xOffset ( ) const
inline

Definition at line 88 of file qtgafile.h.

References XOffset.

◆ yOffset()

int QTgaFile::yOffset ( ) const
inline

Definition at line 93 of file qtgafile.h.

References YOffset.


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