BRL-CAD
Loading...
Searching...
No Matches
anim.h
Go to the documentation of this file.
1/* A N I M . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2026 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20/** @addtogroup libicv
21 *
22 * Functions for creating and manipulating animations (APNG, MJPG)
23 * provided by the LIBICV image processing library.
24 *
25 */
26/** @{ */
27/** @file include/icv/anim.h */
28
29#ifndef ICV_ANIM_H
30#define ICV_ANIM_H
31
32#include "common.h"
33#include "icv/defines.h"
34
35__BEGIN_DECLS
36
37/** Supported animation formats */
43
44/** Opaque animation object */
45typedef struct icv_anim icv_anim_t;
46
47/**
48 * Create a new empty animation object.
49 *
50 * @param format The output format (ICV_ANIM_APNG or ICV_ANIM_MJPG).
51 * @param width The canvas width (can be 0 to auto-detect based on frames).
52 * @param height The canvas height (can be 0 to auto-detect based on frames).
53 * @param fps The default frames per second for the animation.
54 */
55ICV_EXPORT extern icv_anim_t *icv_anim_create(icv_anim_format_t format, uint32_t width, uint32_t height, int fps);
56
57/**
58 * Read an animation from file into an animation object.
59 *
60 * @param filename The path to the animation file.
61 */
62ICV_EXPORT extern icv_anim_t *icv_anim_read(const char *filename);
63
64/**
65 * Write the animation object to a file.
66 *
67 * @param anim The animation object.
68 * @param filename The output file path.
69 */
70ICV_EXPORT extern int icv_anim_write(const icv_anim_t *anim, const char *filename);
71
72/**
73 * Free an animation object.
74 *
75 * @param anim The animation object.
76 * @return 0 on success.
77 */
78ICV_EXPORT extern int icv_anim_destroy(icv_anim_t *anim);
79
80/**
81 * Append a frame to the end of the animation.
82 *
83 * @param anim The animation object.
84 * @param img The frame image data.
85 */
86ICV_EXPORT extern int icv_anim_add_frame(icv_anim_t *anim, const icv_image_t *img);
87
88/**
89 * Insert a frame into the animation at the specified 0-based index.
90 *
91 * @param anim The animation object.
92 * @param index The 0-based insertion index.
93 * @param img The frame image data.
94 */
95ICV_EXPORT extern int icv_anim_insert_frame(icv_anim_t *anim, size_t index, const icv_image_t *img);
96
97/**
98 * Replace a frame in the animation at the specified 0-based index.
99 *
100 * @param anim The animation object.
101 * @param index The 0-based replacement index.
102 * @param img The frame image data.
103 */
104ICV_EXPORT extern int icv_anim_replace_frame(icv_anim_t *anim, size_t index, const icv_image_t *img);
105
106/**
107 * Remove a frame from the animation at the specified 0-based index.
108 *
109 * @param anim The animation object.
110 * @param index The 0-based removal index.
111 */
112ICV_EXPORT extern int icv_anim_remove_frame(icv_anim_t *anim, size_t index);
113
114/**
115 * Extract a specific frame from the animation.
116 *
117 * @param anim The animation object.
118 * @param index The 0-based index of the frame to extract.
119 * @return A newly allocated icv_image_t containing the frame. Must be freed by caller.
120 */
121ICV_EXPORT extern icv_image_t *icv_anim_get_frame(const icv_anim_t *anim, size_t index);
122
123/**
124 * Get the number of frames currently in the animation.
125 *
126 * @param anim The animation object.
127 * @return The number of frames.
128 */
129ICV_EXPORT extern size_t icv_anim_num_frames(const icv_anim_t *anim);
130
131/**
132 * Set the global frames per second for the animation.
133 *
134 * @param anim The animation object.
135 * @param fps The frames per second.
136 * @return 0 on success, -1 on invalid input.
137 */
138ICV_EXPORT extern int icv_anim_set_fps(icv_anim_t *anim, int fps);
139
140/**
141 * Set a specific frame's delay in microseconds. This overrides the global FPS
142 * for this specific frame. (Note: Only fully supported by APNG format. MJPG
143 * will use the global FPS and generally ignore per-frame delays).
144 *
145 * @param anim The animation object.
146 * @param index The 0-based index of the frame.
147 * @param delay_usec The delay in microseconds (1,000,000 = 1 second).
148 */
149ICV_EXPORT extern int icv_anim_set_frame_delay(icv_anim_t *anim, size_t index, uint32_t delay_usec);
150
151__END_DECLS
152
153#endif /* ICV_ANIM_H */
154
155/** @} */
156/*
157 * Local Variables:
158 * tab-width: 8
159 * mode: C
160 * indent-tabs-mode: t
161 * c-file-style: "stroustrup"
162 * End:
163 * ex: shiftwidth=4 tabstop=8
164 */
Header file for the BRL-CAD common definitions.
icv_anim_format_t
Definition anim.h:38
int icv_anim_add_frame(icv_anim_t *anim, const icv_image_t *img)
int icv_anim_set_frame_delay(icv_anim_t *anim, size_t index, uint32_t delay_usec)
icv_image_t * icv_anim_get_frame(const icv_anim_t *anim, size_t index)
int icv_anim_insert_frame(icv_anim_t *anim, size_t index, const icv_image_t *img)
int icv_anim_destroy(icv_anim_t *anim)
int icv_anim_write(const icv_anim_t *anim, const char *filename)
icv_anim_t * icv_anim_create(icv_anim_format_t format, uint32_t width, uint32_t height, int fps)
int icv_anim_set_fps(icv_anim_t *anim, int fps)
int icv_anim_replace_frame(icv_anim_t *anim, size_t index, const icv_image_t *img)
int icv_anim_remove_frame(icv_anim_t *anim, size_t index)
icv_anim_t * icv_anim_read(const char *filename)
size_t icv_anim_num_frames(const icv_anim_t *anim)
struct icv_anim icv_anim_t
Definition anim.h:45
@ ICV_ANIM_APNG
Definition anim.h:40
@ ICV_ANIM_UNKNOWN
Definition anim.h:39
@ ICV_ANIM_MJPG
Definition anim.h:41