From 0b2293a1b44748e494d9db2ae72c72a16b693a9d Mon Sep 17 00:00:00 2001 From: pommicket Date: Wed, 19 Feb 2025 18:43:35 -0500 Subject: configure image format --- camera.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'camera.c') 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 -- cgit v1.2.3