All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Resources

Detailed Description

Loading resources.

Resources are stored in flash and need to be loaded into RAM in order to use them. Below are functions that provide the most rudimentary way of loading resources. See Managing App Resources in Pebble Developer Guide , for information on how to embed resources into your app's bundle.

Function Documentation

ResHandle resource_get_handle ( uint32_t  resource_id)

Gets the resource handle for a file identifier.

Parameters
file_idThe resource ID The resource IDs are auto-generated by the Pebble build process, based on the applib.json. For example, given the following fragment of a applib.json:
...
"resources" : {
"media": [
{
"name": "MY_ICON",
"file": "img/icon.png",
"type": "png",
},
...
The "name" value gets prefixed by RESOURCE_ID_ by the Pebble build process. So, in the example RESOURCE_ID_MY_ICON is the file identifier for that resource. To get a resource handle for that resource write:
ResHandle rh = resource_get_handle(RESOURCE_ID_MY_ICON);
size_t resource_load ( ResHandle  h,
uint8_t *  buffer,
size_t  max_length 
)

Copies the bytes for the resource with a given handle from flash storage into a given buffer.

Parameters
hThe handle to the resource
bufferThe buffer to load the resource data into
max_lengthThe maximum number of bytes to copy
Returns
The number of bytes actually copied
size_t resource_load_byte_range ( ResHandle  h,
uint32_t  start_offset,
uint8_t *  buffer,
size_t  num_bytes 
)

Copies a range of bytes from a resource with a given handle into a given buffer.

Parameters
hThe handle to the resource
start_offsetThe offset in bytes at which to start reading from the resource
dataThe buffer to load the resource data into
num_bytesThe maximum number of bytes to copy
Returns
The number of bytes actually copied
size_t resource_size ( ResHandle  h)

Gets the size of the resource given a resource handle.

Parameters
hThe handle to the resource
Returns
The size of the resource in bytes

Typedef Documentation

typedef const void* ResHandle

Opaque reference to a resource.

See Also
resource_get_handle()