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

Method encode

snap_drawing/src/snap_drawing/cpp/Utils/Image.cpp:131–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131Valdi::Result<Valdi::BytesView> Image::encode(EncodedImageFormat format, double qualityRatio) const {
132 auto quality = static_cast<int>(round(100.0 * qualityRatio));
133
134 auto encoded = Image::encodeSKImageToSKData(*_skImage, format, quality);
135 if (encoded == nullptr) {
136 return Valdi::Error("Cannot encode image");
137 }
138
139 return bytesFromSkData(encoded);
140}
141
142Ref<Image> Image::resized(int width, int height) const {
143 SkBitmap bitmap;

Callers

nothing calls this directly

Calls 3

roundFunction · 0.85
bytesFromSkDataFunction · 0.85
ErrorInterface · 0.50

Tested by

no test coverage detected