All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Luminous::ImageCodecDDS Class Reference

Image codec to handle DDS files. More...

#include <Luminous/ImageCodecDDS.hpp>

Inheritance diagram for Luminous::ImageCodecDDS:
Luminous::ImageCodec

Public Member Functions

bool canRead (QFile &file)
 Can this codec read the given file? The method should examine the file contents and return true if this codec can read it. More...
 
QString extensions () const
 Get the extensions associated with this codec in a string separated by spaces. More...
 
QString name () const
 Return name of the codec. More...
 
bool ping (ImageInfo &info, QFile &file)
 Pinging an image just reads the width, height, and pixel format from a file. More...
 
bool read (Image &image, QFile &file)
 Read the image data from the given file. More...
 
bool read (CompressedImage &image, QFile &file, int level=0)
 Read compressed image data from the given file. More...
 
bool write (const Image &image, QFile &file)
 Store the given Image into a file. More...
 
bool writeMipmaps (const QString &filename, PixelFormat::Compression format, Nimble::Size size, int mipmaps, const std::vector< unsigned char > &dxt)
 Save the DXT compressed image data to a DDS file. More...
 

Static Public Member Functions

static Nimble::Size bufferSize (Nimble::Size size)
 Gets the required buffer size in pixels for the DDS image. More...
 
static int linearSize (Nimble::Size size, PixelFormat::Compression format)
 Gets the size of a single line in bytes. More...
 

Detailed Description

Image codec to handle DDS files.

Member Function Documentation

static Nimble::Size Luminous::ImageCodecDDS::bufferSize ( Nimble::Size  size)
static

Gets the required buffer size in pixels for the DDS image.

DXT compression is done in 4x4 blocks. This function gets the required image size in pixels by rounding the size up to nearest one divisible by four.

Parameters
sizesize of the original image
Returns
size required for the DXT compression
bool Luminous::ImageCodecDDS::canRead ( QFile &  file)
virtual

Can this codec read the given file? The method should examine the file contents and return true if this codec can read it.

The function must not change the current position in the file.

Parameters
filefile to examine
Returns
true if the codec can read the image data stored in the file, false if it can't

Implements Luminous::ImageCodec.

QString Luminous::ImageCodecDDS::extensions ( ) const
virtual

Get the extensions associated with this codec in a string separated by spaces.

Returns
extensions separated by spaces (eg. "jpeg jpg")

Implements Luminous::ImageCodec.

static int Luminous::ImageCodecDDS::linearSize ( Nimble::Size  size,
PixelFormat::Compression  format 
)
static

Gets the size of a single line in bytes.

Parameters
sizeimage dimensions
formatcompression format used
Returns
size of a line in bytes
QString Luminous::ImageCodecDDS::name ( ) const
virtual

Return name of the codec.

Returns
name of the codec

Implements Luminous::ImageCodec.

bool Luminous::ImageCodecDDS::ping ( ImageInfo info,
QFile &  file 
)
virtual

Pinging an image just reads the width, height, and pixel format from a file.

Parameters
infoImageInfo struct to store the read info to
filefile to read from
Returns
true if the reading succeeded, false otherwise

Implements Luminous::ImageCodec.

bool Luminous::ImageCodecDDS::read ( Image image,
QFile &  file 
)
virtual

Read the image data from the given file.

Parameters
imageImage to store the data into
filefile to read the data from
Returns
true if the file was decoded successfully, false otherwise

Implements Luminous::ImageCodec.

bool Luminous::ImageCodecDDS::read ( CompressedImage image,
QFile &  file,
int  level = 0 
)
virtual

Read compressed image data from the given file.

Parameters
imageimage to read to
filefile to read from
levelmipmap level to read
Returns
true if the file was decoded successfully, false otherwise

Reimplemented from Luminous::ImageCodec.

bool Luminous::ImageCodecDDS::write ( const Image image,
QFile &  file 
)
virtual

Store the given Image into a file.

Parameters
imageImage to store
filefile to write to
Returns
true if the encoding was successful, false otherwise

Implements Luminous::ImageCodec.

bool Luminous::ImageCodecDDS::writeMipmaps ( const QString &  filename,
PixelFormat::Compression  format,
Nimble::Size  size,
int  mipmaps,
const std::vector< unsigned char > &  dxt 
)

Save the DXT compressed image data to a DDS file.

Parameters
filenamefile to save to
formatcompression format
sizesize of the image in pixels
mipmapsnumber of mipmap levels in the data
dxtcompressed image data
Returns
true if the writing succeeded