MCPcopy Create free account
hub / github.com/Tencent/tgfx / Encode

Method Encode

src/core/ImageCodec.cpp:124–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124std::shared_ptr<Data> ImageCodec::Encode(const Pixmap& pixmap, EncodedFormat format, int quality) {
125 if (pixmap.isEmpty()) {
126 return nullptr;
127 }
128 USE(format);
129 if (quality > 100) {
130 quality = 100;
131 }
132 if (quality < 0) {
133 quality = 0;
134 }
135#ifdef TGFX_USE_JPEG_ENCODE
136 if (format == EncodedFormat::JPEG) {
137 return JpegCodec::Encode(pixmap, quality);
138 }
139#endif
140#ifdef TGFX_USE_WEBP_ENCODE
141 if (format == EncodedFormat::WEBP) {
142 return WebpCodec::Encode(pixmap, quality);
143 }
144#endif
145#ifdef TGFX_USE_PNG_ENCODE
146 if (format == EncodedFormat::PNG) {
147 return PngCodec::Encode(pixmap, quality);
148 }
149#endif
150 return nullptr;
151}
152
153bool ImageCodec::readPixels(const ImageInfo& dstInfo, void* dstPixels) const {
154 if (dstInfo.width() > width() || dstInfo.height() > height()) {

Callers

nothing calls this directly

Calls 1

isEmptyMethod · 0.45

Tested by

no test coverage detected