Convert .tgs with go libraries (and cgo) (telegram) (#1569)

This commit adds support for go/cgo tgs conversion when building with the -tags `cgo`
The default binaries are still "pure" go and uses the old way of converting.

* Move lottie_convert.py conversion code to its own file

* Add optional libtgsconverter

* Update vendor

* Apply suggestions from code review

* Update bridge/helper/libtgsconverter.go

Co-authored-by: Wim <wim@42.be>
This commit is contained in:
Benau
2021-08-25 04:32:50 +08:00
committed by GitHub
parent d4195deb3a
commit 53cafa9f3d
310 changed files with 121526 additions and 85 deletions

View File

@@ -0,0 +1,59 @@
/*
* configure stb_image about
* the image we will support
*/
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_JPEG
#define STBI_ONLY_PNG
#define STBI_NO_HDR
#define STBI_NO_LINEAR
#define STBI_NO_GIF
#define STBI_NO_PIC
#include "vector_stb_stb_image.h"
#if defined _WIN32 || defined __CYGWIN__
#ifdef RLOTTIE_BUILD
#define RLOTTIE_API __declspec(dllexport)
#else
#define RLOTTIE_API __declspec(dllimport)
#endif
#else
#ifdef RLOTTIE_BUILD
#define RLOTTIE_API __attribute__ ((visibility ("default")))
#else
#define RLOTTIE_API
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* exported function wrapper from the library
*/
RLOTTIE_API unsigned char *lottie_image_load(char const *filename, int *x,
int *y, int *comp, int req_comp)
{
return stbi_load(filename, x, y, comp, req_comp);
}
RLOTTIE_API unsigned char *lottie_image_load_from_data(const char *imageData,
int len, int *x, int *y,
int *comp, int req_comp)
{
unsigned char *data = (unsigned char *)imageData;
return stbi_load_from_memory(data, len, x, y, comp, req_comp);
}
RLOTTIE_API void lottie_image_free(unsigned char *data)
{
stbi_image_free(data);
}
#ifdef __cplusplus
}
#endif