/**
 * @file sd_jpg_browser.h
 * @brief 💾 SD 卡 JPG 浏览与解码
 */

#ifndef SD_JPG_BROWSER_H_
#define SD_JPG_BROWSER_H_

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#include "esp_err.h"

#ifdef __cplusplus
extern "C" {
#endif

#define SD_JPG_MOUNT_POINT      "/sdcard"
#define SD_JPG_MAX_FILES        32

typedef struct {
    uint8_t *data;
    size_t data_size;
    uint16_t width;
    uint16_t height;
} sd_jpg_image_t;

esp_err_t sd_jpg_browser_init(void);
esp_err_t sd_jpg_browser_rescan(void);
bool sd_jpg_browser_is_mounted(void);
size_t sd_jpg_browser_count(void);
size_t sd_jpg_browser_unsupported_image_count(void);
const char *sd_jpg_browser_name(size_t index);
const char *sd_jpg_browser_path(size_t index);
esp_err_t sd_jpg_browser_decode_fit(size_t index, uint16_t max_w, uint16_t max_h, sd_jpg_image_t *out_image);
void sd_jpg_browser_free_image(sd_jpg_image_t *image);

#ifdef __cplusplus
}
#endif

#endif /* SD_JPG_BROWSER_H_ */
