image_dec.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright 2016 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. // All-in-one library to decode PNG/JPEG/WebP/TIFF/WIC input images.
  11. //
  12. // Author: Skal (pascal.massimino@gmail.com)
  13. #ifndef WEBP_IMAGEIO_IMAGE_DEC_H_
  14. #define WEBP_IMAGEIO_IMAGE_DEC_H_
  15. #include "webp/types.h"
  16. #ifdef HAVE_CONFIG_H
  17. #include "webp/config.h"
  18. #endif
  19. #include "./metadata.h"
  20. #include "./jpegdec.h"
  21. #include "./pngdec.h"
  22. #include "./pnmdec.h"
  23. #include "./tiffdec.h"
  24. #include "./webpdec.h"
  25. #include "./wicdec.h"
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. typedef enum {
  30. WEBP_PNG_FORMAT = 0,
  31. WEBP_JPEG_FORMAT,
  32. WEBP_TIFF_FORMAT,
  33. WEBP_WEBP_FORMAT,
  34. WEBP_PNM_FORMAT,
  35. WEBP_UNSUPPORTED_FORMAT
  36. } WebPInputFileFormat;
  37. // Try to infer the image format. 'data_size' should be larger than 12.
  38. // Returns WEBP_UNSUPPORTED_FORMAT if format can't be guess safely.
  39. WebPInputFileFormat WebPGuessImageType(const uint8_t* const data,
  40. size_t data_size);
  41. // Signature for common image-reading functions (ReadPNG, ReadJPEG, ...)
  42. typedef int (*WebPImageReader)(const uint8_t* const data, size_t data_size,
  43. struct WebPPicture* const pic,
  44. int keep_alpha, struct Metadata* const metadata);
  45. // Return the reader associated to a given file format.
  46. WebPImageReader WebPGetImageReader(WebPInputFileFormat format);
  47. // This function is similar to WebPGuessImageType(), but returns a
  48. // suitable reader function. The returned reader is never NULL, but
  49. // unknown formats will return an always-failing valid reader.
  50. WebPImageReader WebPGuessImageReader(const uint8_t* const data,
  51. size_t data_size);
  52. #ifdef __cplusplus
  53. } // extern "C"
  54. #endif
  55. #endif // WEBP_IMAGEIO_IMAGE_DEC_H_