1 | /* |
2 | * Copyright 2017 Google Inc. |
3 | * |
4 | * Use of this source code is governed by a BSD-style license that can be |
5 | * found in the LICENSE file. |
6 | */ |
7 | |
8 | #ifndef SkWebpEncoder_DEFINED |
9 | #define SkWebpEncoder_DEFINED |
10 | |
11 | #include "include/encode/SkEncoder.h" |
12 | |
13 | class SkWStream; |
14 | |
15 | namespace SkWebpEncoder { |
16 | |
17 | enum class Compression { |
18 | kLossy, |
19 | kLossless, |
20 | }; |
21 | |
22 | struct SK_API Options { |
23 | /** |
24 | * |fCompression| determines whether we will use webp lossy or lossless compression. |
25 | * |
26 | * |fQuality| must be in [0.0f, 100.0f]. |
27 | * If |fCompression| is kLossy, |fQuality| corresponds to the visual quality of the |
28 | * encoding. Decreasing the quality will result in a smaller encoded image. |
29 | * If |fCompression| is kLossless, |fQuality| corresponds to the amount of effort |
30 | * put into the encoding. Lower values will compress faster into larger files, |
31 | * while larger values will compress slower into smaller files. |
32 | * |
33 | * This scheme is designed to match the libwebp API. |
34 | */ |
35 | Compression fCompression = Compression::kLossy; |
36 | float fQuality = 100.0f; |
37 | }; |
38 | |
39 | /** |
40 | * Encode the |src| pixels to the |dst| stream. |
41 | * |options| may be used to control the encoding behavior. |
42 | * |
43 | * Returns true on success. Returns false on an invalid or unsupported |src|. |
44 | */ |
45 | SK_API bool Encode(SkWStream* dst, const SkPixmap& src, const Options& options); |
46 | } |
47 | |
48 | #endif |
49 | |