PtexWriter Class Reference

Interface for writing data to a ptex file. More...

#include <Ptexture.h>

List of all members.

Public Member Functions

virtual void release ()=0
 Release resources held by this pointer (pointer becomes invalid).
virtual void setBorderModes (Ptex::BorderMode uBorderMode, Ptex::BorderMode vBorderMode)=0
 Set border modes.
virtual void setEdgeFilterMode (Ptex::EdgeFilterMode edgeFilterMode)=0
 Set edge filter mode.
virtual void writeMeta (const char *key, const char *string)=0
 Write a string as meta data.
virtual void writeMeta (const char *key, const int8_t *value, int count)=0
 Write an array of signed 8-bit integers as meta data.
virtual void writeMeta (const char *key, const int16_t *value, int count)=0
 Write an array of signed 16-bit integers as meta data.
virtual void writeMeta (const char *key, const int32_t *value, int count)=0
 Write an array of signed 32-bit integers as meta data.
virtual void writeMeta (const char *key, const float *value, int count)=0
 Write an array of signed 32-bit floats as meta data.
virtual void writeMeta (const char *key, const double *value, int count)=0
 Write an array of signed 32-bit doubles as meta data.
virtual void writeMeta (PtexMetaData *data)=0
 Copy meta data from an existing meta data block.
virtual bool writeFace (int faceid, const Ptex::FaceInfo &info, const void *data, int stride=0)=0
 Write texture data for a face.
virtual bool writeConstantFace (int faceid, const Ptex::FaceInfo &info, const void *data)=0
 Write constant texture data for a face.
virtual bool close (Ptex::String &error)=0
 Close the file.

Static Public Member Functions

static PTEXAPI PtexWriteropen (const char *path, Ptex::MeshType mt, Ptex::DataType dt, int nchannels, int alphachan, int nfaces, Ptex::String &error, bool genmipmaps=true)
 Open a new texture file for writing.
static PTEXAPI PtexWriteredit (const char *path, bool incremental, Ptex::MeshType mt, Ptex::DataType dt, int nchannels, int alphachan, int nfaces, Ptex::String &error, bool genmipmaps=true)
 Open an existing texture file for writing.
static PTEXAPI bool applyEdits (const char *path, Ptex::String &error)
 Apply edits to a file.

Protected Member Functions

virtual ~PtexWriter ()
 Destructor not for public use. Use release() instead.

Detailed Description

Interface for writing data to a ptex file.

Note: if an alpha channel is specified, then the textures being written to the file are expected to have unmultiplied-alpha data. Generated mipmaps will be premultiplied by the Ptex library. On read, PtexTexture will (if requested) premultiply all textures by alpha when getData is called; by default only reductions are premultiplied. If the source textures are already premultiplied, then alphachan can be set to -1 and the library will just leave all the data as-is. The only reason to store unmultiplied-alpha textures in the file is to preserve the original texture data for later editing.


Member Function Documentation

static PTEXAPI bool PtexWriter::applyEdits ( const char *  path,
Ptex::String error 
) [static]

Apply edits to a file.

If a file has pending edits, the edits will be applied and the file will be regenerated with no edits. This is equivalent to calling edit() with incremental set to false. The advantage is that the file attributes such as mesh type, data type, etc., don't need to be known in advance.

virtual bool PtexWriter::close ( Ptex::String error  )  [pure virtual]

Close the file.

This operation can take some time if mipmaps are being generated or if there are many edit blocks. If an error occurs while writing, false is returned and an error string is written into the error parameter.

static PTEXAPI PtexWriter* PtexWriter::edit ( const char *  path,
bool  incremental,
Ptex::MeshType  mt,
Ptex::DataType  dt,
int  nchannels,
int  alphachan,
int  nfaces,
Ptex::String error,
bool  genmipmaps = true 
) [static]

Open an existing texture file for writing.

If the incremental param is specified as true, then data values written to the file are appended to the file as "edit blocks". This is the fastest way to write data to the file, but edit blocks are slower to read back, and they have no mipmaps so filtering can be inefficient.

If incremental is false, then the edits are applied to the file and the entire file is regenerated on close as if it were written all at once with open().

If the file doesn't exist it will be created and written as if open() were used. If the file exists, the mesh type, data type, number of channels, alpha channel, and number of faces must agree with those stored in the file.

static PTEXAPI PtexWriter* PtexWriter::open ( const char *  path,
Ptex::MeshType  mt,
Ptex::DataType  dt,
int  nchannels,
int  alphachan,
int  nfaces,
Ptex::String error,
bool  genmipmaps = true 
) [static]

Open a new texture file for writing.

Parameters:
path Path to file.
mt Type of mesh for which the textures are defined.
dt Type of data stored within file.
nchannels Number of data channels.
alphachan Index of alpha channel, [0..nchannels-1] or -1 if no alpha channel is present.
nfaces Number of faces in mesh.
error String containing error message if open failed.
genmipmaps Specify true if mipmaps should be generated.
virtual void PtexWriter::release (  )  [pure virtual]

Release resources held by this pointer (pointer becomes invalid).

virtual bool PtexWriter::writeConstantFace ( int  faceid,
const Ptex::FaceInfo info,
const void *  data 
) [pure virtual]

Write constant texture data for a face.

The data is written as a single constant texel value. Note: the resolution specified in the info param may indicate a resolution greater than 1x1 and the value will be preserved when reading. This is useful to indicate a texture's logical resolution even when the data is constant.

virtual bool PtexWriter::writeFace ( int  faceid,
const Ptex::FaceInfo info,
const void *  data,
int  stride = 0 
) [pure virtual]

Write texture data for a face.

The data is assumed to be channel-interleaved per texel and stored in v-major order.

Parameters:
faceid Face index [0..nfaces-1].
info Face resolution and adjacency information.
data Texel data.
stride Distance between rows, in bytes (if zero, data is assumed packed).

If an error is encountered while writing, false is returned and an error message can be retrieved when close is called.

virtual void PtexWriter::writeMeta ( PtexMetaData data  )  [pure virtual]

Copy meta data from an existing meta data block.

virtual void PtexWriter::writeMeta ( const char *  key,
const double *  value,
int  count 
) [pure virtual]

Write an array of signed 32-bit doubles as meta data.

The key must be a null-terminated string.

virtual void PtexWriter::writeMeta ( const char *  key,
const float *  value,
int  count 
) [pure virtual]

Write an array of signed 32-bit floats as meta data.

The key must be a null-terminated string.

virtual void PtexWriter::writeMeta ( const char *  key,
const int32_t *  value,
int  count 
) [pure virtual]

Write an array of signed 32-bit integers as meta data.

The key must be a null-terminated string.

virtual void PtexWriter::writeMeta ( const char *  key,
const int16_t *  value,
int  count 
) [pure virtual]

Write an array of signed 16-bit integers as meta data.

The key must be a null-terminated string.

virtual void PtexWriter::writeMeta ( const char *  key,
const int8_t *  value,
int  count 
) [pure virtual]

Write an array of signed 8-bit integers as meta data.

The key must be a null-terminated string.

virtual void PtexWriter::writeMeta ( const char *  key,
const char *  string 
) [pure virtual]

Write a string as meta data.

Both the key and string params must be null-terminated strings.


Generated on 14 Dec 2015 for Ptex by  doxygen 1.6.1