SketchUp C API

- Main Page
- Related Pages
- Data Structures
- Files

- Data Structures
- Data Structure Index
- Class Hierarchy
- Data Fields

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Related Functions
SUImageRepRef Struct Reference

References an image representation object. More...

`#include <SketchUpAPI/model/image_rep.h>`

## Related Functions
(Note that these are not member functions.)
enum SUResult | SUImageRepCreate (SUImageRepRef *image)
| Creates a new image object with no image data. Image data can be set using any of SUImageRepCopy, SUImageRepSetData, SUImageRepLoadFile. More...
enum SUResult | SUImageRepRelease (SUImageRepRef *image)
| Releases an image object. More...
enum SUResult | SUImageRepCopy (SUImageRepRef image, SUImageRepRef copy_image)
| Copies data from the copy_image to image. More...
enum SUResult | SUImageRepSetData (SUImageRepRef image, size_t width, size_t height, size_t bits_per_pixel, size_t row_padding, const SUByte pixel_data[])
| Sets the image data for the given image. Makes a copy of the data rather than taking ownership. More...
enum SUResult | SUImageRepLoadFile (SUImageRepRef image, const char *file_path)
| Loads image data from the specified file into the provided image. More...
enum SUResult | SUImageRepSaveToFile (SUImageRepRef image, const char *file_path)
| Saves an image object to an image file specified by a path. More...
enum SUResult | SUImageRepGetPixelDimensions (SUImageRepRef image, size_t *width, size_t *height)
| Retrieves the width and height dimensions of an image object in pixels. More...
enum SUResult | SUImageRepGetRowPadding (SUImageRepRef image, size_t *row_padding)
| Retrieves the size of the row padding of an image, in bytes. More...
enum SUResult | SUImageRepResize (SUImageRepRef image, size_t width, size_t height)
| Resizes the dimensions of an image object to the given width and height in pixels. More...
enum SUResult | SUImageRepConvertTo32BitsPerPixel (SUImageRepRef image)
| Converts an image object to be 32 bits per pixel. More...
enum SUResult | SUImageRepGetDataSize (SUImageRepRef 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 SUImageRepGetData(). 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...
enum SUResult | SUImageRepGetData (SUImageRepRef 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 SUImageRepGetDataSize(). More...
enum SUResult | SUImageRepGetDataAsColors (SUImageRepRef image, SUColor color_data[])
| Returns the color data of an image in a SUColor array. More...
enum SUResult | SUImageRepGetColorAtUV (SUImageRepRef image, double u, double v, bool bilinear, SUColor *color)
| Returns the color data given by the UV texture coordinates. More...

## Detailed Description

References an image representation object.

Since
  SketchUp 2017, API 5.0

## Friends And Related Function Documentation

enum SUResult SUImageRepConvertTo32BitsPerPixel | ( | SUImageRepRef | image | ) |
| related

Converts an image object to be 32 bits per pixel.

Since
  SketchUp 2017, API 5.0

Parameters

  [in] | image | The image object.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image is not a valid object
  - SU_ERROR_NO_DATA if image contains no data

enum SUResult SUImageRepCopy | ( | SUImageRepRef | image,
|  | SUImageRepRef | copy_image
| ) |  |
| related

Copies data from the copy_image to image.

Since
  SketchUp 2017, API 5.0

Parameters

  [in,out] | image | The image object to be altered.
  [in] | copy_image | The original image to copy from.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image or copy_image are not a valid objects

enum SUResult SUImageRepCreate | ( | SUImageRepRef * | image | ) |
| related

Creates a new image object with no image data. Image data can be set using any of SUImageRepCopy, SUImageRepSetData, SUImageRepLoadFile.

Since
  SketchUp 2017, API 5.0

Parameters

  [out] | image | The image object created.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_NULL_POINTER_OUTPUT if image is NULL
  - SU_ERROR_OVERWRITE_VALID if image already references a valid object

enum SUResult SUImageRepGetColorAtUV | ( | SUImageRepRef | image,
|  | double | u,
|  | double | v,
|  | bool | bilinear,
|  | SUColor * | color
| ) |  |
| related

Returns the color data given by the UV texture coordinates.

Since
  SketchUp 2018, API 6.0

Parameters

  [in] | image | The image object.
  [in] | u | The U texture coordinate.
  [in] | v | The V texture coordinate.
  [in] | bilinear | The flag to set bilinear texture filtering. This interpolates the colors instead of picking the nearest neighbor.
  [out] | color | The returned color.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image is an invalid object
  - SU_ERROR_NULL_POINTER_OUTPUT if color is NULL

enum SUResult SUImageRepGetData | ( | SUImageRepRef | image,
|  | size_t | data_size,
|  | SUByte | pixel_data[]
| ) |  |
| related

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 SUImageRepGetDataSize().

Since
  SketchUp 2017, API 5.0

Parameters

  [in] | image | The image object.
  [in] | data_size | The size of the byte array.
  [out] | pixel_data | The image data retrieved.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image is an invalid object
  - SU_ERROR_NULL_POINTER_OUTPUT if pixel_data is NULL
  - SU_ERROR_INSUFFICIENT_SIZE if data_size is insufficient for the image data

enum SUResult SUImageRepGetDataAsColors | ( | SUImageRepRef | image,
|  | SUColor | color_data[]
| ) |  |
| related

Returns the color data of an image in a SUColor array.

Since
  SketchUp 2018, API 6.0

Parameters

  [in] | image | The image object.
  [out] | color_data | The SUColor data retrieved.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image is an invalid object
  - SU_ERROR_NULL_POINTER_OUTPUT if color_data is NULL
  - SU_ERROR_UNSUPPORTED if the bytes per pixel of the image is invalid

enum SUResult SUImageRepGetDataSize | ( | SUImageRepRef | image,
|  | size_t * | data_size,
|  | size_t * | bits_per_pixel
| ) |  |
| related

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 SUImageRepGetData(). 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.

Since
  SketchUp 2017, API 5.0

Parameters

  [in] | image | The image object.
  [out] | data_size | The total size of the image data in bytes.
  [out] | bits_per_pixel | The number of bits per pixel of the image data.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image is an invalid object
  - SU_ERROR_NULL_POINTER_OUTPUT if data_size or bits_per_pixel is NULL

enum SUResult SUImageRepGetPixelDimensions | ( | SUImageRepRef | image,
|  | size_t * | width,
|  | size_t * | height
| ) |  |
| related

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

Since
  SketchUp 2017, API 5.0

Parameters

  [in] | image | The image object.
  [out] | width | The width dimension retrieved.
  [out] | height | The height dimension retrieved.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image is not a valid object
  - SU_ERROR_NULL_POINTER_OUTPUT if width or height is NULL

enum SUResult SUImageRepGetRowPadding | ( | SUImageRepRef | image,
|  | size_t * | row_padding
| ) |  |
| related

Retrieves the size of the row padding of an image, in bytes.

Since
  SketchUp 2017, API 5.0

Parameters

  [in] | image | The image object.
  [out] | row_padding | The row padding retrieved.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image is not a valid object
  - SU_ERROR_NULL_POINTER_OUTPUT if row_padding is NULL

enum SUResult SUImageRepLoadFile | ( | SUImageRepRef | image,
|  | const char * | file_path
| ) |  |
| related

Loads image data from the specified file into the provided image.

Since
  SketchUp 2017, API 5.0

Parameters

  [in,out] | image | The image object used to load the file.
  [in] | file_path | The file path of the source image file. Assumed to be UTF-8 encoded.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image is not a valid object
  - SU_ERROR_NULL_POINTER_OUTPUT if file_path is NULL
  - SU_ERROR_SERIALIZATION if the load operation fails

enum SUResult SUImageRepRelease | ( | SUImageRepRef * | image | ) |
| related

Releases an image object.

Since
  SketchUp 2017, API 5.0

Parameters

  [in] | image | The image object.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image is an invalid object
  - SU_ERROR_NULL_POINTER_INPUT if image is NULL

enum SUResult SUImageRepResize | ( | SUImageRepRef | image,
|  | size_t | width,
|  | size_t | height
| ) |  |
| related

Resizes the dimensions of an image object to the given width and height in pixels.

Since
  SketchUp 2017, API 5.0

Parameters

  [in] | image | The image object.
  [in] | width | The new width.
  [in] | height | The new height.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image is not a valid object
  - SU_ERROR_OUT_OF_RANGE if width or height are 0

enum SUResult SUImageRepSaveToFile | ( | SUImageRepRef | image,
|  | const char * | file_path
| ) |  |
| related

Saves an image object to an image file specified by a path.

Since
  SketchUp 2017, API 5.0

Parameters

  [in] | image | The image object.
  [in] | file_path | The file path of the destination image file. Assumed to be UTF-8 encoded.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image is not a valid object
  - SU_ERROR_NULL_POINTER_INPUT if file_path is NULL
  - SU_ERROR_NO_DATA if image contains no data
  - SU_ERROR_SERIALIZATION if the save operation fails

enum SUResult SUImageRepSetData | ( | SUImageRepRef | image,
|  | size_t | width,
|  | size_t | height,
|  | size_t | bits_per_pixel,
|  | size_t | row_padding,
|  | const SUByte | pixel_data[]
| ) |  |
| related

Sets the image data for the given image. Makes a copy of the data rather than taking ownership.

Since
  SketchUp 2017, API 5.0

Parameters

  [in,out] | image | The image object used to load the data.
  [in] | width | The width of the image in pixels.
  [in] | height | The height of the image in pixels.
  [in] | bits_per_pixel | The number of bits per pixel.
  [in] | row_padding | The size in Bytes of row padding in each row of pixel_data.
  [in] | pixel_data | The raw image data.

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if image is not a valid object
  - SU_ERROR_NULL_POINTER_INPUT if pixel_data is NULL
  - SU_ERROR_OUT_OF_RANGE if width or height are 0
  - SU_ERROR_OUT_OF_RANGE if bits per pixel is not 8, 24, or 32

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

- SketchUpAPI/model/defs.h
- SketchUpAPI/model/image_rep.h