SketchUp C API
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
image.h File Reference
#include <SketchUpAPI/color.h>
#include <SketchUpAPI/unicodestring.h>
#include <SketchUpAPI/transformation.h>
#include <SketchUpAPI/model/defs.h>

Go to the source code of this file.

Functions

SU_EXPORT SUEntityRef SUImageToEntity (SUImageRef image)
 Converts from an SUImageRef to an SUEntityRef. This is essentially an upcast operation. More...
 
SU_EXPORT SUImageRef SUImageFromEntity (SUEntityRef entity)
 Converts from an SUEntityRef to an SUImageRef. This is essentially a downcast operation so the given entity must be convertible to an SUImageRef. More...
 
SU_EXPORT SUDrawingElementRef SUImageToDrawingElement (SUImageRef image)
 Converts from an SUImageRef to an SUDrawingElementRef. This is essentially an upcast operation. More...
 
SU_EXPORT SUImageRef SUImageFromDrawingElement (SUDrawingElementRef drawing_elem)
 Converts from an SUDrawingElementRef to an SUImageRef. This is essentially a downcast operation so the given element must be convertible to an SUImageRef. More...
 
SU_RESULT SUImageCreateFromFile (SUImageRef *image, const char *file_path)
 Creates a new image object from an image file specified by a path. The created image must be subsequently added to the Entities of a model, component definition or a group. Use SUModelRemoveComponentDefinitions to remove the image from a model. More...
 
SU_RESULT SUImageCreateFromImageRep (SUImageRef *image, SUImageRepRef image_rep)
 Creates a new SketchUp model image object from an image representation object. The created image must be subsequently added to the Entities of a model, component definition or a group. Use SUModelRemoveComponentDefinitions to remove the image from a model. More...
 
SU_RESULT SUImageGetImageRep (SUImageRef image, SUImageRepRef *image_rep)
 Retrieves a basic image from a SketchUp model image. The given image representation object must have been constructed using one of the SUImageRepCreate* functions. It must be released using SUImageRepRelease. afterwards. More...
 
SU_RESULT SUImageGetName (SUImageRef image, SUStringRef *name)
 Retrieves the name of an image object. More...
 
SU_RESULT SUImageSetName (SUImageRef image, const char *name)
 Sets the name of an image object. More...
 
SU_RESULT SUImageGetTransform (SUImageRef image, struct SUTransformation *transform)
 Retrieves the 3-dimensional homogeneous transform of an image object. More...
 
SU_RESULT SUImageSetTransform (SUImageRef image, const struct SUTransformation *transform)
 Sets the 3-dimensional homogeneous transform of an image object. More...
 
SU_RESULT SUImageGetFileName (SUImageRef image, SUStringRef *file_name)
 Retrieves the image file name of an image object. More...
 
SU_RESULT SUImageGetDimensions (SUImageRef image, double *width, double *height)
 Retrieves the world dimensions of an image object. More...
 
SU_RESULT SUImageGetPixelDimensions (SUImageRef image, size_t *width, size_t *height)
 Retrieves the width and height dimensions of an image object in pixels. More...
 
SU_RESULT SUImageGetDataSize (SUImageRef image, size_t *data_size, size_t *bits_per_pixel)
 Returns the total size and bits-per-pixel value of an image. This function is useful to determine the size of the buffer necessary to be passed into SUImageGetData. The returned data can be used along with the returned bits-per-pixel value and the image dimensions to compute RGBA values at individual pixels of the image. More...
 
SU_RESULT SUImageGetData (SUImageRef image, size_t data_size, SUByte pixel_data[])
 Returns the pixel data for an image. The given array must be large enough to hold the image's data. This size can be obtained by calling SUImageGetDataSize. More...
 

Function Documentation

SU_RESULT SUImageCreateFromFile ( SUImageRef image,
const char *  file_path 
)

Creates a new image object from an image file specified by a path. The created image must be subsequently added to the Entities of a model, component definition or a group. Use SUModelRemoveComponentDefinitions to remove the image from a model.

Parameters
[out]imageThe image object created.
[in]file_pathThe file path of the source image file. Assumed to be UTF-8 encoded.
Returns
SU_RESULT SUImageCreateFromImageRep ( SUImageRef image,
SUImageRepRef  image_rep 
)

Creates a new SketchUp model image object from an image representation object. The created image must be subsequently added to the Entities of a model, component definition or a group. Use SUModelRemoveComponentDefinitions to remove the image from a model.

Since
SketchUp 2017, API 5.0
Parameters
[out]imageThe image object created.
[in]image_repThe basic image object retrieved.
Returns
SU_EXPORT SUImageRef SUImageFromDrawingElement ( SUDrawingElementRef  drawing_elem)

Converts from an SUDrawingElementRef to an SUImageRef. This is essentially a downcast operation so the given element must be convertible to an SUImageRef.

Parameters
[in]drawing_elemThe given element reference.
Returns
  • The converted SUImageRef if the downcast operation succeeds
  • If not, the returned reference will be invalid
SU_EXPORT SUImageRef SUImageFromEntity ( SUEntityRef  entity)

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

Parameters
[in]entityThe given entity reference.
Returns
  • The converted SUImageRef if the downcast operation succeeds. If not, the returned reference will be invalid
SU_RESULT SUImageGetData ( SUImageRef  image,
size_t  data_size,
SUByte  pixel_data[] 
)

Returns the pixel data for an image. The given array must be large enough to hold the image's data. This size can be obtained by calling SUImageGetDataSize.

Deprecated:
Will be removed in the next version of the SketchUp API. The functionality is replaced by SUImageGetImageRep followed by SUImageRepGetData.
Parameters
[in]imageThe image object.
[in]data_sizeThe size of the byte array.
[out]pixel_dataThe image data retrieved.
Returns
SU_RESULT SUImageGetDataSize ( SUImageRef  image,
size_t *  data_size,
size_t *  bits_per_pixel 
)

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

Deprecated:
Will be removed in the next version of the SketchUp API. The functionality is replaced by SUImageGetImageRep followed by SUImageRepGetDataSize.
Parameters
[in]imageThe image 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 SUImageGetDimensions ( SUImageRef  image,
double *  width,
double *  height 
)

Retrieves the world dimensions of an image object.

Parameters
[in]imageThe image object.
[out]widthThe width dimension retrieved.
[out]heightThe height dimension retrieved.
Returns
SU_RESULT SUImageGetFileName ( SUImageRef  image,
SUStringRef file_name 
)

Retrieves the image file name of an image object.

Parameters
[in]imageThe image object.
[out]file_nameThe image file name retrieved.
Returns
SU_RESULT SUImageGetImageRep ( SUImageRef  image,
SUImageRepRef image_rep 
)

Retrieves a basic image from a SketchUp model image. The given image representation object must have been constructed using one of the SUImageRepCreate* functions. It must be released using SUImageRepRelease. afterwards.

Since
SketchUp 2017, API 5.0
Parameters
[in]imageThe texture object.
[out]image_repThe basic image object retrieved.
Returns
SU_RESULT SUImageGetName ( SUImageRef  image,
SUStringRef name 
)

Retrieves the name of an image object.

Parameters
[in]imageThe image object.
[out]nameThe name retrieved.
Returns
SU_RESULT SUImageGetPixelDimensions ( SUImageRef  image,
size_t *  width,
size_t *  height 
)

Retrieves the width and height dimensions of an image object in pixels.

Deprecated:
Will be removed in the next version of the SketchUp API. The functionality is replaced by SUImageGetImageRep followed by SUImageRepGetPixelDimensions.
Parameters
[in]imageThe image object.
[out]widthThe width dimension retrieved.
[out]heightThe height dimension retrieved.
Returns
SU_RESULT SUImageGetTransform ( SUImageRef  image,
struct SUTransformation transform 
)

Retrieves the 3-dimensional homogeneous transform of an image object.

Parameters
[in]imageThe image object.
[out]transformThe transform retrieved.
Returns
SU_RESULT SUImageSetName ( SUImageRef  image,
const char *  name 
)

Sets the name of an image object.

Parameters
[in]imageThe image object.
[in]nameThe name to set. Assumed to be UTF-8 encoded.
Returns
SU_RESULT SUImageSetTransform ( SUImageRef  image,
const struct SUTransformation transform 
)

Sets the 3-dimensional homogeneous transform of an image object.

Parameters
[in]imageThe image object.
[in]transformThe affine transform to set.
Returns
SU_EXPORT SUDrawingElementRef SUImageToDrawingElement ( SUImageRef  image)

Converts from an SUImageRef to an SUDrawingElementRef. This is essentially an upcast operation.

Parameters
[in]imageThe given image reference.
Returns
  • The converted SUEntityRef if image is a valid image
  • If not, the returned reference will be invalid
SU_EXPORT SUEntityRef SUImageToEntity ( SUImageRef  image)

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

Parameters
[in]imageThe given image reference.
Returns
  • The converted SUEntityRef if image is a valid image.
  • If not, the returned reference will be invalid.