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