Skia
2D Graphics Library
SkImageEncoder.h File Reference
Include dependency graph for SkImageEncoder.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

SK_API bool SkEncodeImage (SkWStream *dst, const SkPixmap &src, SkEncodedImageFormat format, int quality)
 Encode SkPixmap in the given binary image format. More...
 
SK_API bool SkEncodeImage (SkWStream *dst, const SkBitmap &src, SkEncodedImageFormat f, int q)
 The following helper function wraps SkEncodeImage(). More...
 
SK_API sk_sp< SkDataSkEncodePixmap (const SkPixmap &src, SkEncodedImageFormat format, int quality)
 Encode SkPixmap in the given binary image format. More...
 
SK_API sk_sp< SkDataSkEncodeBitmap (const SkBitmap &src, SkEncodedImageFormat format, int quality)
 Helper that extracts the pixmap from the bitmap, and then calls SkEncodePixmap() More...
 

Function Documentation

◆ SkEncodeBitmap()

SK_API sk_sp<SkData> SkEncodeBitmap ( const SkBitmap src,
SkEncodedImageFormat  format,
int  quality 
)

Helper that extracts the pixmap from the bitmap, and then calls SkEncodePixmap()

◆ SkEncodeImage() [1/2]

SK_API bool SkEncodeImage ( SkWStream dst,
const SkBitmap src,
SkEncodedImageFormat  f,
int  q 
)

The following helper function wraps SkEncodeImage().

◆ SkEncodeImage() [2/2]

SK_API bool SkEncodeImage ( SkWStream dst,
const SkPixmap src,
SkEncodedImageFormat  format,
int  quality 
)

Encode SkPixmap in the given binary image format.

Parameters
dstresults are written to this stream.
srcsource pixels.
formatimage format, not all formats are supported.
qualityrange from 0-100, this is supported by jpeg and webp. higher values correspond to improved visual quality, but less compression.
Returns
false iff input is bad or format is unsupported.

Will always return false if Skia is compiled without image encoders.

For SkEncodedImageFormat::kWEBP, if quality is 100, it will use lossless compression. Otherwise it will use lossy.

For examples of encoding an image to a file or to a block of memory, see tools/ToolUtils.h.

◆ SkEncodePixmap()

SK_API sk_sp<SkData> SkEncodePixmap ( const SkPixmap src,
SkEncodedImageFormat  format,
int  quality 
)

Encode SkPixmap in the given binary image format.

Parameters
srcsource pixels.
formatimage format, not all formats are supported.
qualityrange from 0-100, this is supported by jpeg and webp. higher values correspond to improved visual quality, but less compression.
Returns
encoded data or nullptr if input is bad or format is unsupported.

Will always return nullptr if Skia is compiled without image encoders.

For SkEncodedImageFormat::kWEBP, if quality is 100, it will use lossless compression. Otherwise it will use lossy.