Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
SkPngEncoder Namespace Reference

Classes

struct  Options
 

Enumerations

enum class  FilterFlag : int {
  kZero = 0x00 , kNone = 0x08 , kSub = 0x10 , kUp = 0x20 ,
  kAvg = 0x40 , kPaeth = 0x80 , kAll = kNone | kSub | kUp | kAvg | kPaeth
}
 

Functions

FilterFlag operator| (FilterFlag x, FilterFlag y)
 
SK_API bool Encode (SkWStream *dst, const SkPixmap &src, const Options &options)
 
SK_API sk_sp< SkDataEncode (GrDirectContext *ctx, const SkImage *img, const Options &options)
 
SK_API std::unique_ptr< SkEncoderMake (SkWStream *dst, const SkPixmap &src, const Options &options)
 

Enumeration Type Documentation

◆ FilterFlag

enum class SkPngEncoder::FilterFlag : int
strong
Enumerator
kZero 
kNone 
kSub 
kUp 
kAvg 
kPaeth 
kAll 

Definition at line 29 of file SkPngEncoder.h.

29 : int {
30 kZero = 0x00,
31 kNone = 0x08,
32 kSub = 0x10,
33 kUp = 0x20,
34 kAvg = 0x40,
35 kPaeth = 0x80,
36 kAll = kNone | kSub | kUp | kAvg | kPaeth,
37};
@ kUp
Definition embedder.h:971

Function Documentation

◆ Encode() [1/2]

sk_sp< SkData > SkPngEncoder::Encode ( GrDirectContext ctx,
const SkImage img,
const Options options 
)

Encode the provided image and return the resulting bytes. If the image was created as a texture-backed image on a GPU context, that |ctx| must be provided so the pixels can be read before being encoded. For raster-backed images, |ctx| can be nullptr. |options| may be used to control the encoding behavior.

Returns nullptr if the pixels could not be read or encoding otherwise fails.

Definition at line 25 of file SkPngEncoder_none.cpp.

25 {
26 SkDEBUGFAIL("Using encoder stub");
27 return nullptr;
28}
#define SkDEBUGFAIL(message)
Definition SkAssert.h:118

◆ Encode() [2/2]

bool SkPngEncoder::Encode ( SkWStream dst,
const SkPixmap src,
const Options options 
)

Encode the |src| pixels to the |dst| stream. |options| may be used to control the encoding behavior.

Returns true on success. Returns false on an invalid or unsupported |src|.

Definition at line 20 of file SkPngEncoder_none.cpp.

20 {
21 SkDEBUGFAIL("Using encoder stub");
22 return false;
23}

◆ Make()

std::unique_ptr< SkEncoder > SkPngEncoder::Make ( SkWStream dst,
const SkPixmap src,
const Options options 
)

Create a png encoder that will encode the |src| pixels to the |dst| stream. |options| may be used to control the encoding behavior.

The primary use of this is incremental encoding of the pixels.

|dst| is unowned but must remain valid for the lifetime of the object.

This returns nullptr on an invalid or unsupported |src|.

Definition at line 471 of file SkPngEncoderImpl.cpp.

471 {
472 if (!SkPixmapIsValid(src)) {
473 return nullptr;
474 }
475
476 std::unique_ptr<SkPngEncoderMgr> encoderMgr = SkPngEncoderMgr::Make(dst);
477 if (!encoderMgr) {
478 return nullptr;
479 }
480
481 if (!encoderMgr->setHeader(src.info(), options)) {
482 return nullptr;
483 }
484
485 if (!encoderMgr->setColorSpace(src.info(), options)) {
486 return nullptr;
487 }
488
489 if (!encoderMgr->writeInfo(src.info())) {
490 return nullptr;
491 }
492
493 encoderMgr->chooseProc(src.info());
494
495 return std::make_unique<SkPngEncoderImpl>(std::move(encoderMgr), src);
496}
const char * options
static bool SkPixmapIsValid(const SkPixmap &src)
static std::unique_ptr< SkPngEncoderMgr > Make(SkWStream *stream)

◆ operator|()

FilterFlag SkPngEncoder::operator| ( FilterFlag  x,
FilterFlag  y 
)
inline

Definition at line 39 of file SkPngEncoder.h.

39{ return (FilterFlag)((int)x | (int)y); }
Type::kYUV Type::kRGBA() int(0.7 *637)
double y
double x