summaryrefslogtreecommitdiff
path: root/camera.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-02-19 18:43:35 -0500
committerpommicket <pommicket@gmail.com>2025-02-19 18:43:35 -0500
commit0b2293a1b44748e494d9db2ae72c72a16b693a9d (patch)
treec3c887ca80398682f4760f9c7f8e8692e2baaa89 /camera.c
parent99ffd21ef873cc30ac37c901ddd374fb26d41939 (diff)
configure image format
Diffstat (limited to 'camera.c')
-rw-r--r--camera.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/camera.c b/camera.c
index d1448d0..f064073 100644
--- a/camera.c
+++ b/camera.c
@@ -298,12 +298,18 @@ static uint8_t *camera_curr_frame(Camera *camera) {
assert(camera->userp_frames[camera->curr_frame_idx]);
return camera->userp_frames[camera->curr_frame_idx];
}
-void camera_write_jpg(Camera *camera, const char *name, int quality) {
+void camera_save_jpg(Camera *camera, const char *name, int quality) {
uint8_t *frame = camera_curr_frame(camera);
if (frame) {
stbi_write_jpg(name, camera_frame_width(camera), camera_frame_height(camera), 3, frame, quality);
}
}
+void camera_save_png(Camera *camera, const char *name) {
+ uint8_t *frame = camera_curr_frame(camera);
+ if (frame) {
+ stbi_write_png(name, camera_frame_width(camera), camera_frame_height(camera), 3, frame, camera_frame_width(camera) * 3);
+ }
+}
bool camera_next_frame(Camera *camera) {
struct pollfd pollfd = {.fd = camera->fd, .events = POLLIN};
// check whether there is any data available from camera