2017-05-05 18:02:13 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkWebpEncoder_DEFINED
|
|
|
|
#define SkWebpEncoder_DEFINED
|
|
|
|
|
|
|
|
#include "SkEncoder.h"
|
|
|
|
|
|
|
|
class SkWStream;
|
|
|
|
|
2017-05-11 17:10:06 +00:00
|
|
|
namespace SkWebpEncoder {
|
2017-05-05 18:02:13 +00:00
|
|
|
|
2017-05-17 10:09:25 +00:00
|
|
|
enum class Compression {
|
2017-05-16 21:06:52 +00:00
|
|
|
kLossy,
|
|
|
|
kLossless,
|
|
|
|
};
|
|
|
|
|
2017-05-11 17:10:06 +00:00
|
|
|
struct SK_API Options {
|
2017-05-05 18:02:13 +00:00
|
|
|
/**
|
2017-05-16 21:06:52 +00:00
|
|
|
* |fCompression| determines whether we will use webp lossy or lossless compression.
|
|
|
|
*
|
|
|
|
* |fQuality| must be in [0.0f, 100.0f].
|
|
|
|
* If |fCompression| is kLossy, |fQuality| corresponds to the visual quality of the
|
|
|
|
* encoding. Decreasing the quality will result in a smaller encoded image.
|
|
|
|
* If |fCompression| is kLossless, |fQuality| corresponds to the amount of effort
|
|
|
|
* put into the encoding. Lower values will compress faster into larger files,
|
|
|
|
* while larger values will compress slower into smaller files.
|
|
|
|
*
|
|
|
|
* This scheme is designed to match the libwebp API.
|
2017-05-05 18:02:13 +00:00
|
|
|
*/
|
2017-05-16 21:06:52 +00:00
|
|
|
Compression fCompression = Compression::kLossy;
|
2017-05-05 18:02:13 +00:00
|
|
|
float fQuality = 100.0f;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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|.
|
|
|
|
*/
|
2017-05-11 17:10:06 +00:00
|
|
|
SK_API bool Encode(SkWStream* dst, const SkPixmap& src, const Options& options);
|
2019-02-11 14:12:25 +00:00
|
|
|
}
|
2017-05-05 18:02:13 +00:00
|
|
|
|
|
|
|
#endif
|