MCPcopy Create free account
hub / github.com/Snapchat/Valdi / loadImage

Function loadImage

libs/image_toolbox/src/image_toolbox/ImageToolbox.cpp:42–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42static Valdi::Result<Ref<Image>> loadImage(const Valdi::StringBox& imageFilePath,
43 const std::optional<int>& widthHint,
44 const std::optional<int>& heightHint) {
45 return processImage<Valdi::Ref<snap::drawing::Image>>(
46 imageFilePath,
47 [&](auto bytes) { return Image::make(bytes); },
48 [&](auto bytes) {
49 auto outputWidth = widthHint ? widthHint.value() : 0;
50 auto outputHeight = heightHint ? heightHint.value() : 0;
51
52 return SVGRenderer::render(bytes.data(), bytes.size(), outputWidth, outputHeight);
53 });
54}
55
56static Valdi::Result<Ref<Image>> clipImageToCircle(const Ref<Image>& image) {
57 auto width = image->width();

Callers 2

TEST_FFunction · 0.85
convertImageFunction · 0.85

Calls 4

valueMethod · 0.65
renderFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45

Tested by 1

TEST_FFunction · 0.68