github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/image/jxr/jxrlib/include/jxr.h (about) 1 // Copyright 2014 <chaishushan{AT}gmail.com>. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #ifndef JXR_H_ 6 #define JXR_H_ 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 // ---------------------------------------------------------------------------- 13 // Exported types 14 // ---------------------------------------------------------------------------- 15 16 typedef struct jxr_decoder_t jxr_decoder_t; 17 typedef struct jxr_encoder_t jxr_encoder_t; 18 19 typedef enum jxr_bool_t { 20 jxr_true = 1, 21 jxr_false = 0, 22 } jxr_bool_t; 23 24 typedef enum jxr_data_type_t { 25 jxr_unsigned = 0, 26 jxr_signed = 1, 27 jxr_float = 2, 28 } jxr_data_type_t; 29 30 typedef struct jxr_rect_t { 31 int x; 32 int y; 33 int width; 34 int height; 35 } jxr_rect_t; 36 37 // ---------------------------------------------------------------------------- 38 // decode/encode simple api 39 // ---------------------------------------------------------------------------- 40 41 jxr_bool_t jxr_decode_config( 42 const char* data, int size, 43 int* width, int* height, int* channels, int* depth, 44 jxr_data_type_t* type 45 ); 46 47 jxr_bool_t jxr_decode( 48 char* buf, int buf_len, int stride, const char* data, int size, 49 int* width, int* height, int* channels, int* depth, 50 jxr_data_type_t* type 51 ); 52 53 jxr_bool_t jxr_encode_len( 54 const char* data, int data_size, int stride, 55 int width, int height, int channels, int depth, 56 int quality, jxr_data_type_t type, 57 int* size 58 ); 59 60 jxr_bool_t jxr_encode( 61 char* buf, int buf_len, 62 const char* data, int data_size, int stride, 63 int width, int height, int channels, int depth, 64 int quality, jxr_data_type_t type, 65 int* size 66 ); 67 68 // ---------------------------------------------------------------------------- 69 // decoder 70 // ---------------------------------------------------------------------------- 71 72 jxr_decoder_t* jxr_decoder_new(); 73 void jxr_decoder_delete(jxr_decoder_t* p); 74 75 jxr_bool_t jxr_decoder_init(jxr_decoder_t* p, const char* data, int size); 76 77 int jxr_decoder_width(jxr_decoder_t* p); 78 int jxr_decoder_height(jxr_decoder_t* p); 79 int jxr_decoder_channels(jxr_decoder_t* p); 80 int jxr_decoder_depth(jxr_decoder_t* p); 81 int jxr_decoder_data_type(jxr_decoder_t* p); 82 83 jxr_bool_t jxr_decoder_decode(jxr_decoder_t* p, const jxr_rect_t* r, char* buf, int stride); 84 85 // ---------------------------------------------------------------------------- 86 // encoder 87 // ---------------------------------------------------------------------------- 88 89 jxr_encoder_t* jxr_encoder_new(); 90 void jxr_encoder_delete(jxr_encoder_t* p); 91 92 jxr_bool_t jxr_encoder_init(jxr_encoder_t* p, 93 const char* data, int size, int stride, 94 int width, int height, int channels, int depth, 95 int quality, jxr_data_type_t type 96 ); 97 98 jxr_bool_t jxr_encoder_need_buffer_size(jxr_encoder_t* p, int* size); 99 jxr_bool_t jxr_encoder_encode(jxr_encoder_t* p, char* buf, int buf_len, int* size); 100 101 // ---------------------------------------------------------------------------- 102 // END 103 // ---------------------------------------------------------------------------- 104 105 #ifdef __cplusplus 106 } // extern "C" 107 #endif 108 #endif // JXR_H_