fix: 对不支持weak的bsp, luat_http_client_onevent报重复定义了
[LuatOS.git] / components / tiny_jpeg / tiny_jpeg.h
blob215d71a5ea3e5b2cc840be876353dfb36800fa6c
1 // ============================================================
2 // Public interface:
3 // ============================================================
5 #ifndef TJE_HEADER_GUARD
6 #define TJE_HEADER_GUARD
7 #include "bsp_common.h"
8 #define TJEI_BUFFER_SIZE 1024
10 #ifdef _WIN32
12 #include <windows.h>
13 #ifndef snprintf
14 #define snprintf sprintf_s
15 #endif
16 // Not quite the same but it works for us. If I am not mistaken, it differs
17 // only in the return value.
19 #endif
21 #if 0
23 #define tje_log DBG
25 #else // NDEBUG
26 #define tje_log(...)
27 #endif // NDEBUG
33 #ifdef __cplusplus
34 extern "C"
36 #endif
38 #if defined(__GNUC__) || defined(__clang__)
39 #pragma GCC diagnostic push
40 #pragma GCC diagnostic ignored "-Wmissing-field-initializers" // We use {0}, which will zero-out the struct.
41 #pragma GCC diagnostic ignored "-Wmissing-braces"
42 #pragma GCC diagnostic ignored "-Wpadded"
43 #endif
45 // - tje_encode_with_func -
47 // Usage
48 // Same as tje_encode_to_file_at_quality, but it takes a callback that knows
49 // how to handle (or ignore) `context`. The callback receives an array `data`
50 // of `size` bytes, which can be written directly to a file. There is no need
51 // to free the data.
53 typedef void tje_write_func(void* context, void* data, int size);
54 void *jpeg_encode_init(tje_write_func* func, void* context, uint8_t quality, uint32_t width, uint32_t height, uint8_t src_num_components);
55 void jpeg_encode_run(void *ctx, uint8_t *src_data);
56 void jpeg_encode_end(void *ctx);
57 // ============================================================
59 #if defined(__GNUC__) || defined(__clang__)
60 #pragma GCC diagnostic pop
61 #endif
64 #ifdef __cplusplus
65 } // extern C
66 #endif
67 #endif