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

Go to the source code of this file.

Data Structures

struct  SUColorOrder
 A simple struct with four indices indicating the ordering of color data within 32-bit bitmap images. 32-bit bitmap images have 4 channels per pixel: red, green, blue, and alpha where the alpha channel indicates the transparency of the pixel. SketchUpAPI expects the channels to be in different orders on Windows vs. Mac OS. Bitmap data is exposed in BGRA and RGBA byte orders on Windows and Mac OS, respectively. The color order indices facilitate platform independent code when it is necessary to manipulate image pixel data. The struct's data also applies to 24-bit bitmap images except that such images don't have an alpha channel so the alpha_index varaible can be ignored. More...
 

Functions

SU_EXPORT struct SUColorOrder SUGetColorOrder ()
 Retrieves a SUColorOrder indicating the order of color bytes within 32-bit images' pixel data. More...
 
SU_RESULT SUImageRepCreate (SUImageRepRef *image)
 Creates a new image object with no image data. Image data can be set using any of SUImageRepCopy, SUImageRepSetData, SUImageRepLoadFile. More...
 
SU_RESULT SUImageRepRelease (SUImageRepRef *image)
 Releases an image object. More...
 
SU_RESULT SUImageRepCopy (SUImageRepRef image, SUImageRepRef copy_image)
 Copies data from the copy_image to image. More...
 
SU_RESULT 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...
 
SU_RESULT SUImageRepLoadFile (SUImageRepRef image, const char *file_path)
 Loads image data from the specified file into the provided image. More...
 
SU_RESULT SUImageRepSaveToFile (SUImageRepRef image, const char *file_path)
 Saves an image object to an image file specified by a path. More...
 
SU_RESULT SUImageRepGetPixelDimensions (SUImageRepRef image, size_t *width, size_t *height)
 Retrieves the width and height dimensions of an image object in pixels. More...
 
SU_RESULT SUImageRepGetRowPadding (SUImageRepRef image, size_t *row_padding)
 Retrieves the size of the row padding of an image, in bytes. More...
 
SU_RESULT 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...
 
SU_RESULT SUImageRepConvertTo32BitsPerPixel (SUImageRepRef image)
 Converts an image object to be 32 bits per pixel. More...
 
SU_RESULT 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...
 
SU_RESULT 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...
 
SU_RESULT SUImageRepGetDataAsColors (SUImageRepRef image, SUColor color_data[])
 Returns the color data of an image in a SUColor array. More...
 
SU_RESULT SUImageRepGetColorAtUV (SUImageRepRef image, double u, double v, bool bilinear, SUColor *color)
 Returns the color data given by the UV texture coordinates. More...
 

Function Documentation

SU_EXPORT struct SUColorOrder SUGetColorOrder ( )
read

Retrieves a SUColorOrder indicating the order of color bytes within 32-bit images' pixel data.

Since
SketchUp 2017, API 5.2
Returns
a SUColorOrder indicating the pixel color ordering of 32bit images.
SU_RESULT SUImageRepConvertTo32BitsPerPixel ( SUImageRepRef  image)

Converts an image object to be 32 bits per pixel.

Since
SketchUp 2017, API 5.0
Parameters
[in]imageThe image object.
Returns
SU_RESULT SUImageRepCopy ( SUImageRepRef  image,
SUImageRepRef  copy_image 
)

Copies data from the copy_image to image.

Since
SketchUp 2017, API 5.0
Parameters
[in,out]imageThe image object to be altered.
[in]copy_imageThe original image to copy from.
Returns
SU_RESULT SUImageRepCreate ( SUImageRepRef image)

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]imageThe image object created.
Returns
SU_RESULT SUImageRepGetColorAtUV ( SUImageRepRef  image,
double  u,
double  v,
bool  bilinear,
SUColor color 
)

Returns the color data given by the UV texture coordinates.

Since
SketchUp 2018, API 6.0
Parameters
[in]imageThe image object.
[in]uThe U texture coordinate.
[in]vThe V texture coordinate.
[in]bilinearThe flag to set bilinear texture filtering. This interpolates the colors instead of picking the nearest neighbor.
[out]colorThe returned color.
Returns
SU_RESULT 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.

Since
SketchUp 2017, API 5.0
Parameters
[in]imageThe image object.
[in]data_sizeThe size of the byte array.
[out]pixel_dataThe image data retrieved.
Returns
SU_RESULT SUImageRepGetDataAsColors ( SUImageRepRef  image,
SUColor  color_data[] 
)

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

Since
SketchUp 2018, API 6.0
Parameters
[in]imageThe image object.
[out]color_dataThe SUColor data retrieved.
Returns
SU_RESULT 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.

Since
SketchUp 2017, API 5.0
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 SUImageRepGetPixelDimensions ( SUImageRepRef  image,
size_t *  width,
size_t *  height 
)

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

Since
SketchUp 2017, API 5.0
Parameters
[in]imageThe image object.
[out]widthThe width dimension retrieved.
[out]heightThe height dimension retrieved.
Returns
SU_RESULT SUImageRepGetRowPadding ( SUImageRepRef  image,
size_t *  row_padding 
)

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

Since
SketchUp 2017, API 5.0
Parameters
[in]imageThe image object.
[out]row_paddingThe row padding retrieved.
Returns
SU_RESULT SUImageRepLoadFile ( SUImageRepRef  image,
const char *  file_path 
)

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

Since
SketchUp 2017, API 5.0
Parameters
[in,out]imageThe image object used to load the file.
[in]file_pathThe file path of the source image file. Assumed to be UTF-8 encoded.
Returns
SU_RESULT SUImageRepRelease ( SUImageRepRef image)

Releases an image object.

Since
SketchUp 2017, API 5.0
Parameters
[in]imageThe image object.
Returns
SU_RESULT SUImageRepResize ( SUImageRepRef  image,
size_t  width,
size_t  height 
)

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

Since
SketchUp 2017, API 5.0
Parameters
[in]imageThe image object.
[in]widthThe new width.
[in]heightThe new height.
Returns
SU_RESULT SUImageRepSaveToFile ( SUImageRepRef  image,
const char *  file_path 
)

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

Since
SketchUp 2017, API 5.0
Parameters
[in]imageThe image object.
[in]file_pathThe file path of the destination image file. Assumed to be UTF-8 encoded.
Returns
SU_RESULT 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.

Since
SketchUp 2017, API 5.0
Parameters
[in,out]imageThe image object used to load the data.
[in]widthThe width of the image in pixels.
[in]heightThe height of the image in pixels.
[in]bits_per_pixelThe number of bits per pixel.
[in]row_paddingThe size in Bytes of row padding in each row of pixel_data.
[in]pixel_dataThe raw image data.
Returns