Ptex

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
PtexWriter Class Referenceabstract

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

`#include <Ptexture.h>`

Inheritance diagram for PtexWriter:

## 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 PtexWriter * | open (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 PtexWriter * | edit (const char *path, 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 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)
| Open an existing texture file for writing.
static bool | applyEdits (const char *path, Ptex::String &error)
| Obsolete (returns true).

## 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.

Definition at line 819 of file Ptexture.h.

## Constructor & Destructor Documentation

## ◆ ~PtexWriter()

virtual PtexWriter::~PtexWriter | ( |  | ) |
| inline protected virtual

Destructor not for public use. Use release() instead.

Definition at line 822 of file Ptexture.h.

## Member Function Documentation

## ◆ applyEdits()

bool PtexWriter::applyEdits | ( | const char * | path,
|  | Ptex::String & | error )
| static

Obsolete (returns true).

Definition at line 175 of file PtexWriter.cpp.

## ◆ close()

virtual bool PtexWriter::close | ( | Ptex::String & | error | ) |
| pure virtual

Close the file.

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

Implemented in PtexMainWriter.

## ◆ edit() [1/2]

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.

(deprecated)

The incremental parameter is no longer used. The file will be written as non-incremental regardless of the value of the parameter. The version of PtexWriter::edit without the incremental parameter should be called instead.

Definition at line 166 of file PtexWriter.cpp.

References edit().

## ◆ edit() [2/2]

PtexWriter * PtexWriter::edit | ( | const char * | path,
|  | 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 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.

Definition at line 119 of file PtexWriter.cpp.

References PtexTexture::alphaChannel(), PtexTexture::dataType(), PtexTexture::meshType(), PtexTexture::numChannels(), PtexTexture::numFaces(), PtexMainWriter::ok(), PtexTexture::open(), and PtexMainWriter::release().

Referenced by edit().

## ◆ open()

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.

Definition at line 100 of file PtexWriter.cpp.

References PtexMainWriter::ok(), and PtexMainWriter::release().

## ◆ release()

virtual void PtexWriter::release | ( |  | ) |
| pure virtual

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

Implemented in PtexMainWriter.

## ◆ setBorderModes()

virtual void PtexWriter::setBorderModes | ( | Ptex::BorderMode | uBorderMode,
|  | Ptex::BorderMode | vBorderMode )
| pure virtual

Set border modes.

Implemented in PtexMainWriter.

## ◆ setEdgeFilterMode()

virtual void PtexWriter::setEdgeFilterMode | ( | Ptex::EdgeFilterMode | edgeFilterMode | ) |
| pure virtual

Set edge filter mode.

Implemented in PtexMainWriter.

## ◆ writeConstantFace()

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.

## ◆ writeFace()

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.

## ◆ writeMeta() [1/7]

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.

Implemented in PtexMainWriter.

## ◆ writeMeta() [2/7]

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.

Implemented in PtexMainWriter.

## ◆ writeMeta() [3/7]

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.

Implemented in PtexMainWriter.

## ◆ writeMeta() [4/7]

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.

Implemented in PtexMainWriter.

## ◆ writeMeta() [5/7]

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.

Implemented in PtexMainWriter.

## ◆ writeMeta() [6/7]

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.

Implemented in PtexMainWriter.

## ◆ writeMeta() [7/7]

virtual void PtexWriter::writeMeta | ( | PtexMetaData * | data | ) |
| pure virtual

Copy meta data from an existing meta data block.

Implemented in PtexMainWriter.

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

- Ptexture.h
- PtexWriter.cpp