SketchUp SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
texture.h File Reference
#include <stddef.h>
#include <slapi/color.h>
#include <slapi/unicodestring.h>
#include <slapi/model/defs.h>

Go to the source code of this file.

Functions

SU_EXPORT SUEntityRef SUTextureToEntity (SUTextureRef texture)
 Converts from an SUTextureRef to an SUEntityRef. This is essentially an upcast operation. More...
 
SU_EXPORT SUTextureRef SUTextureFromEntity (SUEntityRef entity)
 Converts from an SUEntityRef to an SUTextureRef. This is essentially a downcast operation so the given SUEntityRef must be convertible to an SUTextureRef. More...
 
SU_RESULT SUTextureCreateFromImageData (SUTextureRef *texture, size_t width, size_t height, size_t bits_per_pixel, const SUByte pixel_data[])
 Creates a new texture object with the specified image data. If the texture object is not subsequently associated with a parent object (e.g. material), then the texture object must be deallocated with SUTextureRelease. More...
 
SU_RESULT SUTextureCreateFromFile (SUTextureRef *texture, const char *file_path, double s_scale, double t_scale)
 Creates a new texture object from an image file specified by a path. If the texture object is not subsequently associated with a parent object (e.g. material), then the texture object must be deallocated with SUTextureRelease. More...
 
SU_RESULT SUTextureRelease (SUTextureRef *texture)
 Deallocates a texture object and its resources. If the texture object is associated with a parent object (e.g. material) the parent object handles the deallocation of the resources of the texture object and the texture object must not be explicitly deallocated. More...
 
SU_RESULT SUTextureGetDimensions (SUTextureRef texture, size_t *width, size_t *height, double *s_scale, double *t_scale)
 Retrieves the pixel width and height and scale factors of the texture. More...
 
SU_RESULT SUTextureGetImageDataSize (SUTextureRef texture, size_t *data_size, size_t *bits_per_pixel)
 Returns the total size and bits-per-pixel value of a texture's image data. This function is useful to determine the size of the buffer necessary to be passed into SUTextureGetImageData. The returned data can be used along with the returned bits-per-pixel value and the texture dimensions to compute RGBA values at individual pixels of the texture image. More...
 
SU_RESULT SUTextureGetImageData (SUTextureRef texture, size_t data_size, SUByte pixel_data[])
 Returns the texture's image data. The given array must be large enough to hold the texture's image data. This size can be obtained by calling SUTextureGetImageDataSize. More...
 
SU_RESULT SUTextureWriteToFile (SUTextureRef texture, const char *file_path)
 Writes a texture object as an image to disk. More...
 
SU_RESULT SUTextureGetFileName (SUTextureRef texture, SUStringRef *file_name)
 Retrieves the image file name of a texture object. More...
 
SU_RESULT SUTextureGetUseAlphaChannel (SUTextureRef texture, bool *alpha_channel_used)
 Retrieves the value of the flag that indicates whether a texture object uses the alpha channel. More...
 

Function Documentation

SU_RESULT SUTextureCreateFromFile ( SUTextureRef texture,
const char *  file_path,
double  s_scale,
double  t_scale 
)

Creates a new texture object from an image file specified by a path. If the texture object is not subsequently associated with a parent object (e.g. material), then the texture object must be deallocated with SUTextureRelease.

Parameters
[out]textureThe texture object created.
[in]file_pathThe file path of the source image file. Assumed to be UTF-8 encoded.
[in]s_scaleThe scale factor for s coordinate value.
[in]t_scaleThe scale factor for t coordinate value.
Returns
SU_RESULT SUTextureCreateFromImageData ( SUTextureRef texture,
size_t  width,
size_t  height,
size_t  bits_per_pixel,
const SUByte  pixel_data[] 
)

Creates a new texture object with the specified image data. If the texture object is not subsequently associated with a parent object (e.g. material), then the texture object must be deallocated with SUTextureRelease.

Parameters
[out]textureThe texture object created.
[in]widthThe width in pixels of the texture data.
[in]heightThe height in pixels of the texture data.
[in]bits_per_pixelThe number of bits per pixel of the image data.
[in]pixel_dataThe source of the pixel data.
Returns
SU_EXPORT SUTextureRef SUTextureFromEntity ( SUEntityRef  entity)

Converts from an SUEntityRef to an SUTextureRef. This is essentially a downcast operation so the given SUEntityRef must be convertible to an SUTextureRef.

Parameters
[in]entityThe entity reference.
Returns
  • The converted SUTextureRef if the downcast operation succeeds. If not, the returned reference will be invalid.
SU_RESULT SUTextureGetDimensions ( SUTextureRef  texture,
size_t *  width,
size_t *  height,
double *  s_scale,
double *  t_scale 
)

Retrieves the pixel width and height and scale factors of the texture.

Parameters
[in]textureThe texture object whose dimensions are retrieved.
[out]widthThe width dimension retrieved.
[out]heightThe height dimension retrieved.
[out]s_scaleThe scale factor for s retrieved.
[out]t_scaleThe scale factor for t retrieved.
Returns
SU_RESULT SUTextureGetFileName ( SUTextureRef  texture,
SUStringRef file_name 
)

Retrieves the image file name of a texture object.

Parameters
[in]textureThe texture object.
[out]file_nameThe file name retrieved.
Returns
SU_RESULT SUTextureGetImageData ( SUTextureRef  texture,
size_t  data_size,
SUByte  pixel_data[] 
)

Returns the texture's image data. The given array must be large enough to hold the texture's image data. This size can be obtained by calling SUTextureGetImageDataSize.

Parameters
[in]textureThe texture object.
[in]data_sizeThe size of the byte array.
[out]pixel_dataThe image data retrieved.
Returns
SU_RESULT SUTextureGetImageDataSize ( SUTextureRef  texture,
size_t *  data_size,
size_t *  bits_per_pixel 
)

Returns the total size and bits-per-pixel value of a texture's image data. This function is useful to determine the size of the buffer necessary to be passed into SUTextureGetImageData. The returned data can be used along with the returned bits-per-pixel value and the texture dimensions to compute RGBA values at individual pixels of the texture image.

Parameters
[in]textureThe texture object.
[out]data_sizeThe total size of the image data in bytes.
[out]bits_per_pixelThe number of bits per pixel of the image data.
Returns
SU_RESULT SUTextureGetUseAlphaChannel ( SUTextureRef  texture,
bool *  alpha_channel_used 
)

Retrieves the value of the flag that indicates whether a texture object uses the alpha channel.

Parameters
[in]textureThe texture object.
[out]alpha_channel_usedThe destination of the retrieved value.
Returns
SU_RESULT SUTextureRelease ( SUTextureRef texture)

Deallocates a texture object and its resources. If the texture object is associated with a parent object (e.g. material) the parent object handles the deallocation of the resources of the texture object and the texture object must not be explicitly deallocated.

Parameters
[in]textureThe texture object to deallocate.
Returns
SU_EXPORT SUEntityRef SUTextureToEntity ( SUTextureRef  texture)

Converts from an SUTextureRef to an SUEntityRef. This is essentially an upcast operation.

Parameters
[in]textureThe texture reference.
Returns
  • The converted SUEntityRef if texture is a valid object. If not, the returned reference will be invalid.
SU_RESULT SUTextureWriteToFile ( SUTextureRef  texture,
const char *  file_path 
)

Writes a texture object as an image to disk.

Parameters
[in]textureThe texture object.
[in]file_pathThe file path destination of the texture image. Assumed to be UTF-8 encoded.
Returns