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

Classes

struct  Options
 

Enumerations

enum class  AlphaOption { kIgnore , kBlendOnBlack }
 
enum class  Downsample { k420 , k422 , k444 }
 

Functions

SK_API bool Encode (SkWStream *dst, const SkPixmap &src, const Options &options)
 
SK_API bool Encode (SkWStream *dst, const SkYUVAPixmaps &src, const SkColorSpace *srcColorSpace, 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)
 
SK_API std::unique_ptr< SkEncoderMake (SkWStream *dst, const SkYUVAPixmaps &src, const SkColorSpace *srcColorSpace, const Options &options)
 

Enumeration Type Documentation

◆ AlphaOption

enum class SkJpegEncoder::AlphaOption
strong
Enumerator
kIgnore 
kBlendOnBlack 

Definition at line 28 of file SkJpegEncoder.h.

◆ Downsample

enum class SkJpegEncoder::Downsample
strong
Enumerator
k420 

Reduction by a factor of two in both the horizontal and vertical directions.

k422 

Reduction by a factor of two in the horizontal direction.

k444 

No downsampling.

Definition at line 33 of file SkJpegEncoder.h.

33 {
34 /**
35 * Reduction by a factor of two in both the horizontal and vertical directions.
36 */
37 k420,
38
39 /**
40 * Reduction by a factor of two in the horizontal direction.
41 */
42 k422,
43
44 /**
45 * No downsampling.
46 */
47 k444,
48};

Function Documentation

◆ Encode() [1/3]

sk_sp< SkData > SkJpegEncoder::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 SkJpegEncoder_none.cpp.

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

◆ Encode() [2/3]

bool SkJpegEncoder::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 SkJpegEncoder_none.cpp.

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

◆ Encode() [3/3]

bool SkJpegEncoder::Encode ( SkWStream dst,
const SkYUVAPixmaps src,
const SkColorSpace srcColorSpace,
const Options options 
)

Definition at line 401 of file SkJpegEncoderImpl.cpp.

404 {
405 auto encoder = Make(dst, src, srcColorSpace, options);
406 return encoder.get() && encoder->encodeRows(src.yuvaInfo().height());
407}
const char * options
static std::unique_ptr< SkEncoder > Make(SkWStream *dst, const SkPixmap *src, const SkYUVAPixmaps *srcYUVA, const SkColorSpace *srcYUVAColorSpace, const SkJpegEncoder::Options &options)

◆ Make() [1/2]

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

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

|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 424 of file SkJpegEncoderImpl.cpp.

424 {
425 return Make(dst, &src, nullptr, nullptr, options);
426}

◆ Make() [2/2]

std::unique_ptr< SkEncoder > SkJpegEncoder::Make ( SkWStream dst,
const SkYUVAPixmaps src,
const SkColorSpace srcColorSpace,
const Options options 
)

Definition at line 428 of file SkJpegEncoderImpl.cpp.

431 {
432 return Make(dst, nullptr, &src, srcColorSpace, options);
433}