Flutter Engine
The Flutter Engine
Functions
SkPngDecoder Namespace Reference

Functions

SK_API bool IsPng (const void *, size_t)
 
SK_API std::unique_ptr< SkCodecDecode (std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
 
SK_API std::unique_ptr< SkCodecDecode (sk_sp< SkData >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
 
constexpr SkCodecs::Decoder Decoder ()
 

Function Documentation

◆ Decode() [1/2]

std::unique_ptr< SkCodec > SkPngDecoder::Decode ( sk_sp< SkData data,
SkCodec::Result outResult,
SkCodecs::DecodeContext  ctx = nullptr 
)

Definition at line 1252 of file SkPngCodec.cpp.

1254 {
1255 if (!data) {
1256 if (outResult) {
1257 *outResult = SkCodec::kInvalidInput;
1258 }
1259 return nullptr;
1260 }
1261 return Decode(SkMemoryStream::Make(std::move(data)), outResult, ctx);
1262}
@ kInvalidInput
Definition: SkCodec.h:109
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
Definition: SkStream.cpp:314
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ Decode() [2/2]

std::unique_ptr< SkCodec > SkPngDecoder::Decode ( std::unique_ptr< SkStream stream,
SkCodec::Result outResult,
SkCodecs::DecodeContext  ctx = nullptr 
)

Attempts to decode the given bytes as a PNG.

If the bytes are not a PNG, returns nullptr.

DecodeContext, if non-null, is expected to be a SkPngChunkReader*

Definition at line 1238 of file SkPngCodec.cpp.

1240 {
1241 SkCodec::Result resultStorage;
1242 if (!outResult) {
1243 outResult = &resultStorage;
1244 }
1245 SkPngChunkReader* chunkReader = nullptr;
1246 if (ctx) {
1247 chunkReader = static_cast<SkPngChunkReader*>(ctx);
1248 }
1249 return SkPngCodec::MakeFromStream(std::move(stream), outResult, chunkReader);
1250}
Result
Definition: SkCodec.h:76
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, Result *, SkPngChunkReader *=nullptr)

◆ Decoder()

constexpr SkCodecs::Decoder SkPngDecoder::Decoder ( )
inlineconstexpr

Definition at line 38 of file SkPngDecoder.h.

38 {
39 return { "png", IsPng, Decode };
40}
SK_API std::unique_ptr< SkCodec > Decode(sk_sp< SkData >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsPng(const void *, size_t)

◆ IsPng()

bool SkPngDecoder::IsPng ( const void *  data,
size_t  len 
)

Returns true if this data claims to be a PNG image.

Definition at line 1234 of file SkPngCodec.cpp.

1234 {
1235 return SkPngCodec::IsPng(data, len);
1236}
static bool IsPng(const void *, size_t)
Definition: SkPngCodec.cpp:344