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