SkWebpEncoder.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #ifndef SkWebpEncoder_DEFINED
  8. #define SkWebpEncoder_DEFINED
  9. #include "SkEncoder.h"
  10. class SkWStream;
  11. namespace SkWebpEncoder {
  12. enum class Compression {
  13. kLossy,
  14. kLossless,
  15. };
  16. struct SK_API Options {
  17. /**
  18. * |fCompression| determines whether we will use webp lossy or lossless compression.
  19. *
  20. * |fQuality| must be in [0.0f, 100.0f].
  21. * If |fCompression| is kLossy, |fQuality| corresponds to the visual quality of the
  22. * encoding. Decreasing the quality will result in a smaller encoded image.
  23. * If |fCompression| is kLossless, |fQuality| corresponds to the amount of effort
  24. * put into the encoding. Lower values will compress faster into larger files,
  25. * while larger values will compress slower into smaller files.
  26. *
  27. * This scheme is designed to match the libwebp API.
  28. */
  29. Compression fCompression = Compression::kLossy;
  30. float fQuality = 100.0f;
  31. };
  32. /**
  33. * Encode the |src| pixels to the |dst| stream.
  34. * |options| may be used to control the encoding behavior.
  35. *
  36. * Returns true on success. Returns false on an invalid or unsupported |src|.
  37. */
  38. SK_API bool Encode(SkWStream* dst, const SkPixmap& src, const Options& options);
  39. };
  40. #endif