21 const size_t max_thumb_size,
26 NSVGimage *image = nsvgParseFromFile(filepath,
"px", 96.0f);
28 if (image ==
nullptr) {
32 if (image->width == 0 || image->height == 0) {
37 int w = int(image->width);
38 int h = int(image->height);
42 *r_height = size_t(h);
44 NSVGrasterizer *rast = nsvgCreateRasterizer();
45 if (rast ==
nullptr) {
50 const float scale =
float(max_thumb_size) / std::max(
w, h);
51 const int dest_w = std::max(
int(
w * scale), 1);
52 const int dest_h = std::max(
int(h * scale), 1);
55 if (ibuf !=
nullptr) {
56 nsvgRasterize(rast, image, 0, 0, scale, ibuf->
byte_buffer.
data, dest_w, dest_h, dest_w * 4);
60 nsvgDeleteRasterizer(rast);