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 12 #ifndef WEBP_IMAGEIO_WEBPDEC_H_ 13 #define WEBP_IMAGEIO_WEBPDEC_H_ 14 15 #include "webp/decode.h" 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 struct Metadata; 22 struct WebPPicture; 23 24 //------------------------------------------------------------------------------ 25 // WebP decoding 26 27 // Prints an informative error message regarding decode failure of 'in_file'. 28 // 'status' is treated as a VP8StatusCode and if valid will be printed as a 29 // text string. 30 void PrintWebPError(const char* const in_file, int status); 31 32 // Reads a WebP from 'in_file', returning the contents and size in 'data' and 33 // 'data_size'. If not NULL, 'bitstream' is populated using WebPGetFeatures(). 34 // Returns true on success. 35 int LoadWebP(const char* const in_file, 36 const uint8_t** data, size_t* data_size, 37 WebPBitstreamFeatures* bitstream); 38 39 // Decodes the WebP contained in 'data'. 40 // 'config' is a structure previously initialized by WebPInitDecoderConfig(). 41 // 'config->output' should have the desired colorspace selected. 42 // Returns the decoder status. On success 'config->output' will contain the 43 // decoded picture. 44 VP8StatusCode DecodeWebP(const uint8_t* const data, size_t data_size, 45 WebPDecoderConfig* const config); 46 47 // Same as DecodeWebP(), but using the incremental decoder. 48 VP8StatusCode DecodeWebPIncremental( 49 const uint8_t* const data, size_t data_size, 50 WebPDecoderConfig* const config); 51 52 //------------------------------------------------------------------------------ 53 54 // Decodes a WebP contained in 'data', returning the decoded output in 'pic'. 55 // Output is RGBA or YUVA, depending on pic->use_argb value. 56 // If 'keep_alpha' is true and the WebP has an alpha channel, the output is RGBA 57 // or YUVA. Otherwise, alpha channel is dropped and output is RGB or YUV. 58 // Returns true on success. 59 int ReadWebP(const uint8_t* const data, size_t data_size, 60 struct WebPPicture* const pic, 61 int keep_alpha, struct Metadata* const metadata); 62 63 #ifdef __cplusplus 64 } // extern "C" 65 #endif 66 67 #endif // WEBP_IMAGEIO_WEBPDEC_H_ 68