2022-02-24 19:03:36 +00:00
|
|
|
#include <vips/vips8>
|
2020-07-21 14:03:08 +00:00
|
|
|
|
2022-12-28 23:01:50 +00:00
|
|
|
#include "common.h"
|
|
|
|
|
2020-07-21 14:03:08 +00:00
|
|
|
using namespace std;
|
2022-02-24 19:03:36 +00:00
|
|
|
using namespace vips;
|
2020-07-21 14:03:08 +00:00
|
|
|
|
2023-03-09 01:36:39 +00:00
|
|
|
char *Homebrew(string type, string *outType, ArgumentMap Arguments,
|
|
|
|
size_t *DataSize) {
|
2022-12-26 06:28:56 +00:00
|
|
|
string caption = GetArgument<string>(Arguments, "caption");
|
|
|
|
string basePath = GetArgument<string>(Arguments, "basePath");
|
|
|
|
|
|
|
|
string assetPath = basePath + "assets/images/hbc.png";
|
|
|
|
VImage bg = VImage::new_from_file(assetPath.c_str());
|
|
|
|
|
|
|
|
VImage text = VImage::text(
|
|
|
|
".", VImage::option()->set("fontfile",
|
|
|
|
(basePath + "assets/fonts/hbc.ttf").c_str()));
|
|
|
|
text = VImage::text(
|
|
|
|
("<span letter_spacing=\"-5120\" color=\"white\">" + caption + "</span>")
|
|
|
|
.c_str(),
|
|
|
|
VImage::option()
|
|
|
|
->set("rgba", true)
|
|
|
|
->set("align", VIPS_ALIGN_CENTRE)
|
|
|
|
->set("font", "PF Square Sans Pro, Twemoji Color Font 96")
|
|
|
|
->set("fontfile", (basePath + "assets/fonts/twemoji.otf").c_str()));
|
|
|
|
|
|
|
|
VImage out = bg.composite2(text, VIPS_BLEND_MODE_OVER,
|
|
|
|
VImage::option()
|
|
|
|
->set("x", 400 - (text.width() / 2))
|
|
|
|
->set("y", 300 - (text.height() / 2) - 8));
|
|
|
|
|
|
|
|
void *buf;
|
2023-03-09 01:36:39 +00:00
|
|
|
out.write_to_buffer(("." + *outType).c_str(), &buf, DataSize);
|
2022-06-28 03:50:53 +00:00
|
|
|
|
2022-12-26 06:28:56 +00:00
|
|
|
return (char *)buf;
|
2020-07-21 14:03:08 +00:00
|
|
|
}
|