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