go-libwebp

Experimental translation from libwebp to Go source.
Log | Files | Refs | README | LICENSE

imageio_util.h (2534B)


      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 //  Utility functions used by the image decoders.
     11 //
     12 
     13 #ifndef WEBP_IMAGEIO_IMAGEIO_UTIL_H_
     14 #define WEBP_IMAGEIO_IMAGEIO_UTIL_H_
     15 
     16 #include <stdio.h>
     17 
     18 #include "webp/types.h"
     19 
     20 #ifdef __cplusplus
     21 extern "C" {
     22 #endif
     23 
     24 //------------------------------------------------------------------------------
     25 // File I/O
     26 
     27 // Reopen file in binary (O_BINARY) mode.
     28 // Returns 'file' on success, NULL otherwise.
     29 FILE* ImgIoUtilSetBinaryMode(FILE* file);
     30 
     31 // Allocates storage for entire file 'file_name' and returns contents and size
     32 // in 'data' and 'data_size'. Returns 1 on success, 0 otherwise. '*data' should
     33 // be deleted using WebPFree().
     34 // Note: for convenience, the data will be null-terminated with an extra byte
     35 // (not accounted for in *data_size), in case the file is text and intended
     36 // to be used as a C-string.
     37 // If 'file_name' is NULL or equal to "-", input is read from stdin by calling
     38 // the function ImgIoUtilReadFromStdin().
     39 int ImgIoUtilReadFile(const char* const file_name,
     40                       const uint8_t** data, size_t* data_size);
     41 
     42 // Same as ImgIoUtilReadFile(), but reads until EOF from stdin instead.
     43 int ImgIoUtilReadFromStdin(const uint8_t** data, size_t* data_size);
     44 
     45 // Write a data segment into a file named 'file_name'. Returns true if ok.
     46 // If 'file_name' is NULL or equal to "-", output is written to stdout.
     47 int ImgIoUtilWriteFile(const char* const file_name,
     48                        const uint8_t* data, size_t data_size);
     49 
     50 //------------------------------------------------------------------------------
     51 
     52 // Copy width x height pixels from 'src' to 'dst' honoring the strides.
     53 void ImgIoUtilCopyPlane(const uint8_t* src, int src_stride,
     54                         uint8_t* dst, int dst_stride, int width, int height);
     55 
     56 //------------------------------------------------------------------------------
     57 
     58 // Returns 0 in case of overflow, memory over-allocation or excessive dimension.
     59 int ImgIoUtilCheckSizeArgumentsOverflow(uint64_t stride, size_t height);
     60 
     61 #ifdef __cplusplus
     62 }    // extern "C"
     63 #endif
     64 
     65 #endif  // WEBP_IMAGEIO_IMAGEIO_UTIL_H_