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.
Gets the resource handle for a file identifier.
file_id | The 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",
},
...
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);
|
Copies the bytes for the resource with a given handle from flash storage into a given buffer.
h | The handle to the resource |
buffer | The buffer to load the resource data into |
max_length | The maximum number of bytes to copy |
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.
h | The handle to the resource |
start_offset | The offset in bytes at which to start reading from the resource |
data | The buffer to load the resource data into |
num_bytes | The maximum number of bytes to copy |
Gets the size of the resource given a resource handle.
h | The handle to the resource |
typedef const void* ResHandle |
Opaque reference to a resource.