Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
QTgaFile(QIODevice *)
Construct a new QTgaFile object getting data from device.
Definition qtgafile.cpp:102

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 16 of file qtgafile.h.

Member Enumeration Documentation

◆ Compression

Enumerator
NoCompression 
RleCompression 

Definition at line 21 of file qtgafile.h.

◆ FooterOffset

Enumerator
ExtensionOffset 
DeveloperOffset 
SignatureOffset 
FooterSize 

Definition at line 42 of file qtgafile.h.

◆ HeaderOffset

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

Definition at line 26 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 102 of file qtgafile.cpp.

References FooterSize, HeaderSize, height(), ImageType, PixelDepth, SignatureOffset, and width().

Referenced by QTgaHandler::canRead().

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

◆ ~QTgaFile()

QTgaFile::~QTgaFile ( )

Destroy the device, recovering any resources.

Definition at line 168 of file qtgafile.cpp.

Member Function Documentation

◆ compression()

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

Definition at line 114 of file qtgafile.h.

◆ errorMessage()

QString QTgaFile::errorMessage ( ) const
inline

Definition at line 75 of file qtgafile.h.

◆ height()

int QTgaFile::height ( ) const
inline

Definition at line 104 of file qtgafile.h.

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

Here is the caller graph for this function:

◆ isValid()

bool QTgaFile::isValid ( ) const
inline

Definition at line 70 of file qtgafile.h.

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

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 186 of file qtgafile.cpp.

References CMapDepth, ColorMapType, HeaderSize, height(), IdLength, ImageDescriptor, isValid(), PixelDepth, and width().

Here is the call graph for this function:

◆ size()

QSize QTgaFile::size ( ) const
inline

Definition at line 109 of file qtgafile.h.

References height(), and width().

Here is the call graph for this function:

◆ width()

int QTgaFile::width ( ) const
inline

Definition at line 99 of file qtgafile.h.

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

Here is the caller graph for this function:

◆ xOffset()

int QTgaFile::xOffset ( ) const
inline

Definition at line 89 of file qtgafile.h.

◆ yOffset()

int QTgaFile::yOffset ( ) const
inline

Definition at line 94 of file qtgafile.h.


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