int main (int argc, char **argv) { ply_array_t *array; int i; char **data; array = ply_array_new (PLY_ARRAY_ELEMENT_TYPE_POINTER); ply_array_add_pointer_element (array, "foo"); ply_array_add_pointer_element (array, "bar"); ply_array_add_pointer_element (array, "baz"); ply_array_add_pointer_element (array, "qux"); data = (char **) ply_array_get_pointer_elements (array); for (i = 0; data[i] != NULL; i++) { printf ("element '%d' has data '%s'\n", i, data[i]); i++; } ply_array_free (array); return 0; }
static bool ply_progress_animation_add_frame (ply_progress_animation_t *progress_animation, const char *filename) { ply_image_t *image; image = ply_image_new (filename); if (!ply_image_load (image)) { ply_image_free (image); return false; } ply_array_add_pointer_element (progress_animation->frames, image); progress_animation->area.width = MAX (progress_animation->area.width, (size_t) ply_image_get_width (image)); progress_animation->area.height = MAX (progress_animation->area.height, (size_t) ply_image_get_height (image)); return true; }
static bool ply_throbber_add_frame (ply_throbber_t *throbber, const char *filename) { ply_image_t *image; ply_pixel_buffer_t *frame; image = ply_image_new (filename); if (!ply_image_load (image)) { ply_image_free (image); return false; } frame = ply_image_convert_to_pixel_buffer (image); ply_array_add_pointer_element (throbber->frames, frame); throbber->width = MAX (throbber->width, (long) ply_pixel_buffer_get_width (frame)); throbber->height = MAX (throbber->height, (long) ply_pixel_buffer_get_height (frame)); return true; }