2022-06-25 17:40:52 +00:00
|
|
|
#include <vips/vips8>
|
|
|
|
|
2022-12-28 23:01:50 +00:00
|
|
|
#include "common.h"
|
|
|
|
|
2022-06-25 17:40:52 +00:00
|
|
|
using namespace std;
|
|
|
|
using namespace vips;
|
|
|
|
|
2022-12-28 06:20:17 +00:00
|
|
|
char *ToGif(string *type, char *BufferData, size_t BufferLength,
|
|
|
|
ArgumentMap Arguments, size_t *DataSize) {
|
|
|
|
if (*type == "gif") {
|
|
|
|
*DataSize = BufferLength;
|
2023-01-04 04:03:51 +00:00
|
|
|
char *data = (char *)malloc(BufferLength);
|
|
|
|
memcpy(data, BufferData, BufferLength);
|
|
|
|
return data;
|
2022-12-28 06:20:17 +00:00
|
|
|
} else {
|
|
|
|
VOption *options = VImage::option()->set("access", "sequential");
|
|
|
|
|
2022-12-28 23:01:50 +00:00
|
|
|
VImage in = VImage::new_from_buffer(
|
|
|
|
BufferData, BufferLength, "",
|
|
|
|
*type == "webp" ? options->set("n", -1) : options);
|
2022-06-28 03:50:53 +00:00
|
|
|
|
2022-12-28 06:20:17 +00:00
|
|
|
void *buf;
|
|
|
|
in.write_to_buffer(".gif", &buf, DataSize);
|
|
|
|
*type = "gif";
|
|
|
|
|
|
|
|
return (char *)buf;
|
|
|
|
}
|
2022-06-25 17:40:52 +00:00
|
|
|
}
|