Add missing C file
This commit is contained in:
Родитель
77dffddf98
Коммит
02418c08d9
|
@ -0,0 +1,44 @@
|
|||
#include "emscripten.h"
|
||||
#include "src/webp/encode.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
int version() {
|
||||
return WebPGetEncoderVersion();
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
uint8_t* create_buffer(int width, int height) {
|
||||
return malloc(width * height * 4 * sizeof(uint8_t));
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
void destroy_buffer(uint8_t* p) {
|
||||
free(p);
|
||||
}
|
||||
|
||||
int result[2];
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
void encode(uint8_t* img_in, int width, int height, float quality) {
|
||||
uint8_t* img_out;
|
||||
size_t size;
|
||||
size = WebPEncodeRGBA(img_in, width, height, width * 4, quality, &img_out);
|
||||
result[0] = (int)img_out;
|
||||
result[1] = size;
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
void free_result(uint8_t* result) {
|
||||
WebPFree(result);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
int get_result_pointer() {
|
||||
return result[0];
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
int get_result_size() {
|
||||
return result[1];
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче