Flutter Engine
The Flutter Engine
Classes | Namespaces | Functions
encode_platform.cpp File Reference
#include "gm/gm.h"
#include "include/codec/SkEncodedImageFormat.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkData.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSize.h"
#include "include/core/SkStream.h"
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/encode/SkJpegEncoder.h"
#include "include/encode/SkPngEncoder.h"
#include "include/encode/SkWebpEncoder.h"
#include "tools/DecodeUtils.h"
#include "tools/Resources.h"

Go to the source code of this file.

Classes

class  skiagm::EncodePlatformGM
 

Namespaces

namespace  skiagm
 

Functions

static sk_sp< SkDataencode_data (SkEncodedImageFormat type, const SkBitmap &bitmap, int quality)
 

Function Documentation

◆ encode_data()

static sk_sp< SkData > encode_data ( SkEncodedImageFormat  type,
const SkBitmap bitmap,
int  quality 
)
static

Definition at line 44 of file encode_platform.cpp.

44 {
46 if (!bitmap.peekPixels(&src)) {
47 return nullptr;
48 }
50 switch (type) {
52 bool success = SkPngEncoder::Encode(&buf, src, {});
53 return success ? buf.detachAsData() : nullptr;
54 }
57 opts.fQuality = quality;
58 bool success = SkJpegEncoder::Encode(&buf, src, opts);
59 return success ? buf.detachAsData() : nullptr;
60 }
63 opts.fQuality = quality;
64 bool success = SkWebpEncoder::Encode(&buf, src, opts);
65 return success ? buf.detachAsData() : nullptr;
66 }
67 default:
69 }
70}
#define SkUNREACHABLE
Definition: SkAssert.h:135
GLenum type
sk_sp< SkData > detachAsData()
Definition: SkStream.cpp:707
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
Definition: bitmap.py:1