webpdec.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright 2014 Google Inc. All Rights Reserved.
  2. //
  3. // Use of this source code is governed by a BSD-style license
  4. // that can be found in the COPYING file in the root of the source
  5. // tree. An additional intellectual property rights grant can be found
  6. // in the file PATENTS. All contributing project authors may
  7. // be found in the AUTHORS file in the root of the source tree.
  8. // -----------------------------------------------------------------------------
  9. //
  10. // WebP decode.
  11. #ifndef WEBP_IMAGEIO_WEBPDEC_H_
  12. #define WEBP_IMAGEIO_WEBPDEC_H_
  13. #include "webp/decode.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. struct Metadata;
  18. struct WebPPicture;
  19. //------------------------------------------------------------------------------
  20. // WebP decoding
  21. // Prints an informative error message regarding decode failure of 'in_file'.
  22. // 'status' is treated as a VP8StatusCode and if valid will be printed as a
  23. // text string.
  24. void PrintWebPError(const char* const in_file, int status);
  25. // Reads a WebP from 'in_file', returning the contents and size in 'data' and
  26. // 'data_size'. If not NULL, 'bitstream' is populated using WebPGetFeatures().
  27. // Returns true on success.
  28. int LoadWebP(const char* const in_file,
  29. const uint8_t** data, size_t* data_size,
  30. WebPBitstreamFeatures* bitstream);
  31. // Decodes the WebP contained in 'data'.
  32. // 'config' is a structure previously initialized by WebPInitDecoderConfig().
  33. // 'config->output' should have the desired colorspace selected.
  34. // Returns the decoder status. On success 'config->output' will contain the
  35. // decoded picture.
  36. VP8StatusCode DecodeWebP(const uint8_t* const data, size_t data_size,
  37. WebPDecoderConfig* const config);
  38. // Same as DecodeWebP(), but using the incremental decoder.
  39. VP8StatusCode DecodeWebPIncremental(
  40. const uint8_t* const data, size_t data_size,
  41. WebPDecoderConfig* const config);
  42. //------------------------------------------------------------------------------
  43. // Decodes a WebP contained in 'data', returning the decoded output in 'pic'.
  44. // Output is RGBA or YUVA, depending on pic->use_argb value.
  45. // If 'keep_alpha' is true and the WebP has an alpha channel, the output is RGBA
  46. // or YUVA. Otherwise, alpha channel is dropped and output is RGB or YUV.
  47. // Returns true on success.
  48. int ReadWebP(const uint8_t* const data, size_t data_size,
  49. struct WebPPicture* const pic,
  50. int keep_alpha, struct Metadata* const metadata);
  51. #ifdef __cplusplus
  52. } // extern "C"
  53. #endif
  54. #endif // WEBP_IMAGEIO_WEBPDEC_H_