sixel_sys_static/
lib.rs

1//! Bindings to libsixel
2//!
3//! libsixel is an encoder/decoder implementation for DEC SIXEL graphics
4//!
5//! > SIXEL is one of image formats for printer and terminal imaging introduced by Digital Equipment Corp. (DEC).
6//! > Its data scheme is represented as a terminal-friendly escape sequence.
7//! > So if you want to view a SIXEL image file, all you have to do is "cat" it to your terminal.
8//!
9//! For additional information, please check [its repo](https://github.com/saitoha/libsixel)
10
11
12use std::os::raw::{c_void, c_int, c_char, c_uchar};
13
14#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
15pub struct Version {
16    pub major: u8,
17    pub minor: u8,
18    pub patch: u8,
19}
20
21pub const VERSION: Version = Version {
22    major: 1,
23    minor: 7,
24    patch: 3,
25};
26
27pub const ABI_VERSION: Version = Version {
28    major: 1,
29    minor: 6,
30    patch: 0,
31};
32
33
34pub const OUTPUT_PACKET_SIZE: u16 = 16384;
35
36pub const PALETTE_MIN: u16 = 2;
37pub const PALETTE_MAX: u16 = 256;
38
39pub const USE_DEPRECATED_SYMBOLS: bool = true;
40
41use status::Status;
42
43pub mod status {
44    use std::os::raw::c_int;
45
46    // In impl crate: function to convert these to enums
47
48    /// Describes why a function returned
49    pub type Status = c_int;
50
51    /// Suceeded
52    pub const OK: Status = 0x0000;
53    /// Failed
54    ///
55    /// Renamed from "FALSE"
56    pub const ERR: Status = 0x1000;
57
58    pub const RUNTIME_ERROR: Status = ERR | 0x0100;
59    pub const LOGIC_ERROR: Status = ERR | 0x0200;
60    pub const FEATURE_ERROR: Status = ERR | 0x0300;
61    pub const LIBC_ERROR: Status = ERR | 0x0400;
62    pub const CURL_ERROR: Status = ERR | 0x0500;
63    pub const JPEG_ERROR: Status = ERR | 0x0600;
64    pub const PNG_ERROR: Status = ERR | 0x0700;
65    pub const GDK_ERROR: Status = ERR | 0x0800;
66    pub const GD_ERROR: Status = ERR | 0x0900;
67    pub const STBI_ERROR: Status = ERR | 0x0a00;
68    pub const STBIW_ERROR: Status = ERR | 0x0b00;
69
70    /// Interrupted by a signal
71    pub const INTERRUPTED: Status = OK | 0x0001;
72
73    /// `malloc()` failed
74    pub const BAD_ALLOCATION: Status = RUNTIME_ERROR | 0x0001;
75    pub const BAD_ARGUMENT: Status = RUNTIME_ERROR | 0x0002;
76    pub const BAD_INPUT: Status = RUNTIME_ERROR | 0x0003;
77
78    /// Feature not implemented
79    pub const NOT_IMPLEMENTED: Status = FEATURE_ERROR | 0x0001;
80}
81
82#[repr(C)]
83#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
84/// Output character size
85pub enum CharacterSize {
86    SevenBit = 0,
87    EightBit = 1,
88}
89
90
91#[repr(C)]
92#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
93/// Method for finding the largest dimension for splitting,
94/// and sorting by that component.
95pub enum MethodForLargest {
96    Auto = 0,
97    /// Simply comparing the range in RGB space
98    Normal = 1,
99    /// Transforming into luminosities before the comparison
100    Luminosity = 2,
101}
102
103#[repr(C)]
104#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
105/// Method for choosing the a color from the box
106pub enum MethodForRepColor {
107    Auto = 0,
108    CenterOfBox = 1,
109    /// Method is described in Heckbert's paper
110    AverageColor = 2,
111    AveragePixels = 3,
112}
113
114#[repr(C)]
115#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
116pub enum DiffusionMethod {
117    Auto = 0,
118    /// Don't diffuse
119    None = 1,
120    /// Use Bill Atkinson's method
121    Atkinson = 2,
122    /// Use Floyd-Steinberg method
123    FS = 3,
124    /// Use Jarvis, Judice, & Ninke method
125    JaJuNi = 4,
126    /// Use Stucki's method
127    Stucki = 5,
128    /// Use Burkes' method
129    Burkes = 6,
130}
131
132#[repr(C)]
133#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
134/// Quality of palette
135pub enum QualityMode {
136    Auto = 0,
137    High = 1,
138    Low = 2,
139    Full = 3,
140    HighColor = 4,
141}
142
143#[repr(C)]
144#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
145pub enum BuiltinDither {
146    /// Monochrome terminal with dark background
147    MonoDark = 0,
148    /// Monochrome terminal with light background
149    ///
150    /// Note: libsixel documentation says it is for a dark background...
151    MonoLight = 1,
152    XTerm16 = 2,
153    XTerm256 = 3,
154    VT340Mono = 4,
155    VT340Color = 5,
156    /// 1 bit grayscale
157    G1 = 6,
158    /// 2 bit grayscale
159    G2 = 7,
160    /// 4 bit grayscale
161    G4 = 8,
162    /// 8 bit grayscale
163    G8 = 9,
164}
165
166#[repr(C)]
167#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
168/// Offset value used for the values of PixelFormat
169pub enum FormatType {
170    Color = 0,
171    Grayscale = 64,
172    Palette = 128,
173}
174
175#[repr(C)]
176#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
177/// Pixel format used in input image
178pub enum PixelFormat {
179    /// 15bpp
180    RGB555 = FormatType::Color as isize | 0x01,
181    /// 16bpp
182    RGB565 = FormatType::Color as isize | 0x02,
183    /// 24bpp
184    RGB888 = FormatType::Color as isize | 0x03,
185    /// 15bpp
186    BGR555 = FormatType::Color as isize | 0x04,
187    /// 16bpp
188    BGR565 = FormatType::Color as isize | 0x05,
189    /// 24bpp
190    BGR888 = FormatType::Color as isize | 0x06,
191    /// 32bpp
192    ARGB8888 = FormatType::Color as isize | 0x10,
193    /// 32bpp
194    RGBA8888 = FormatType::Color as isize | 0x11,
195    /// 32bpp
196    ABGR8888 = FormatType::Color as isize | 0x12,
197    /// 32bpp
198    BGRA8888 = FormatType::Color as isize | 0x13,
199    /// 1bpp grayscale
200    G1 = FormatType::Grayscale as isize | 0x00,
201    /// 2bpp grayscale
202    G2 = FormatType::Grayscale as isize | 0x01,
203    /// 4bpp grayscale
204    G4 = FormatType::Grayscale as isize | 0x02,
205    /// 8bpp grayscale
206    G8 = FormatType::Grayscale as isize | 0x03,
207    /// 16bpp grayscale with alpha
208    AG88 = FormatType::Grayscale as isize | 0x13,
209    /// 16bpp grayscale with alpha
210    GA88 = FormatType::Grayscale as isize | 0x23,
211    /// 1bpp palette
212    Pal1 = FormatType::Palette as isize | 0x00,
213    /// 2bpp palette
214    Pal2 = FormatType::Palette as isize | 0x01,
215    /// 4bpp palette
216    Pal4 = FormatType::Palette as isize | 0x02,
217    /// 8bpp palette
218    Pal8 = FormatType::Palette as isize | 0x03,
219}
220
221#[repr(C)]
222#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
223pub enum PaletteType {
224    Auto = 0,
225    /// HLS colorspace
226    HLS = 1,
227    /// RGB colorspace
228    RGB = 2,
229}
230
231#[repr(C)]
232#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
233/// Policy used when encoding
234pub enum EncodePolicy {
235    Auto = 0,
236    /// Encode as fast as posible
237    Fast = 1,
238    /// Encode to the smallest sixel sequence as possible
239    Size = 2,
240}
241
242#[repr(C)]
243#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
244/// What filter to use when resampling
245pub enum ResamplingMethod {
246    Nearest = 0,
247    Gaussian = 1,
248    Hanning = 2,
249    Hamming = 3,
250    Bilinear = 4,
251    Welsh = 5,
252    Bicubic = 6,
253    Lanczos2 = 7,
254    Lanczos3 = 8,
255    Lanczos4 = 9,
256}
257
258
259#[repr(C)]
260#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
261pub enum ImageFormat {
262    GIF = 0,
263    PNG = 1,
264    BMP = 2,
265    JPG = 3,
266    TGA = 4,
267    WBMP = 5,
268    TIFF = 6,
269    SIXEL = 7,
270    PNM = 8,
271    GD2 = 9,
272    PSD = 10,
273    HDR = 11,
274}
275
276#[repr(C)]
277#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
278/// How to treat GIF animations that loop
279pub enum LoopMode {
280    /// Honor the setting of the GIF header
281    Auto = 0,
282    /// Always loop
283    Force = 1,
284    /// Never loop
285    Disable = 2,
286}
287
288#[repr(u8)]
289#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
290/// Flags used in the easy decoder API.
291pub enum DecoderOptflag {
292    /// Specify input file name
293    Input = b'i',
294    /// Specify output file name
295    Output = b'o',
296}
297
298#[repr(u8)]
299#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
300/// Flags used in the easy encoder API.
301///
302/// Flags are the same as the ones used in the img2sixel executable
303pub enum Optflag {
304    /// Specify output file name
305    OutFile = b'o',
306    /// Use sixel images for 7 bit terminals or printers
307    ///
308    /// Default of the 2 bit mode flags
309    UseSevenBitMode = b'7',
310    /// Use sixel images for 8 bit terminals or printers
311    UseEightBitMode = b'8',
312    /// Limit the arguments of DECGRI('!') to 255
313    HasGRIArgLimit = b'R',
314    /// Specify the number of colors to reduce the image to
315    ///
316    /// Defaults to 256
317    ///
318    /// Renamed from "SIXEL_OPTFLAG_COLORS"
319    NumColors = b'p',
320    /// Give a file that specifies a set of colors
321    ///
322    /// Transforms the image to match the set
323    Mapfile = b'm',
324    /// Output a monochrome sixel image
325    ///
326    /// Assumes the terminal background color is black
327    Monochrome = b'e',
328    /// Connect to SSL sites without certs
329    ///
330    /// Only applicable if libcurl is used
331    Insecure = b'k',
332    /// Assume the terminal background color is white
333    ///
334    /// Only applicable when also using `Optflag::Monochrome`
335    InvertBackground = b'i',
336    /// Output a 15bpp sixel image
337    UseHighColor = b'I',
338    /// Use DECDMAC and DEVINVM sequences to optimize GIF animation rendering
339    UseMacro = b'u',
340    /// Specify a macro register number
341    MacroNumber = b'n',
342    /// Specify the number of arguments for the score of complexion correction
343    ///
344    /// Must be 1 or more
345    ComplexionScore = b'C',
346    /// Ignore delay when rendering GIF animations
347    IgnoreGIFDelay = b'g',
348    /// Render an animated GIF as a static image
349    StaticGIF = b'S',
350    /// Choose a diffusion method to be used with the NumColors option
351    ///
352    /// Should be a [`DiffusionMethod`]
353    /// [`DiffusionMethod`]: enum.DiffusionMethod.html
354    Diffusion = b'd',
355    /// Choose a method for finding the largest dimension of median cut boxes
356    /// for splitting
357    ///
358    /// Should be a [`MethodForLargest`]
359    /// [`MethodForLargest`]: enum.MethodForLargest.html
360    FindLargest = b'f',
361    /// Choose the method for selecting the representative color from each
362    /// median-cut box.
363    ///
364    /// Only makes sense when the `Optflag::NumColors` is used
365    ///
366    /// Should be a [`MethodForRepColor`]
367    /// [`MethodForRepColor`]: enum.MethodForRepColor.html
368    SelectColor = b's',
369    /// Crop a source image to fit some geometry
370    ///
371    /// String format representation is "%dx%d+%d+%d", which is width, height,
372    /// x, y
373    CropRegion = b'c',
374    /// Resize an image to a specified width
375    ///
376    /// Uses the following syntax:
377    ///
378    /// * `auto`
379    ///
380    /// * `<number>%`  scale with a percentage
381    ///
382    /// * `<number>`   scale a number of pixel counts
383    ///
384    /// * `<number>px` scale a number of pixel counts
385    Width = b'w',
386    /// Resize an image to a specified height
387    ///
388    /// Uses the following syntax:
389    ///
390    /// * `auto`
391    ///
392    /// * `<number>%`  scale with a percentage
393    ///
394    /// * `<number>`   scale a number of pixel counts
395    ///
396    /// * `<number>px` scale a number of pixel counts
397    Height = b'h',
398    /// Choose a filter for resampling when scaling the image due to
399    /// `Optflag::Width` or `Optflag::Height`
400    ///
401    /// Should be a [`ResamplingMethod`]
402    /// [`ResamplingMethod`]: enum.ResamplingMethod.html
403    Resampling = b'r',
404    /// Selects quality of color quanlization
405    ///
406    /// Should be a [`QualityMode`]
407    /// [`QualityMode`]: enum.QualityMode.html
408    QualityMode = b'q',
409    /// Select loop behavior for animated GIFs
410    ///
411    /// Should be a [`LoopMode`]
412    /// [`LoopMode`]: enum.LoopMode.html
413    LoopMode = b'l',
414    /// Select a palette color space
415    ///
416    /// Should be a [`PaletteType`]
417    /// [`PaletteType`]: enum.PaletteType.html
418    PaletteType = b't',
419    /// Choose a built-in palette type
420    ///
421    /// Should be a [`BuiltinDither`]
422    /// [`BuiltinDither`]: enum.BuiltinDither.html
423    BuiltinPalette = b'b',
424    /// Choose an encoding policy
425    ///
426    /// Should be a [`EncodePolicy`]
427    /// [`EncodePolicy`]: enum.EncodingPolicy.html
428    EncodingPolicy = b'E',
429    /// Specify a background color
430    ///
431    /// Represented by the following syntax:
432    ///
433    /// ```txt
434    /// #rgb
435    /// #rrggbb
436    /// #rrrgggbbb
437    /// #rrrrggggbbbb
438    /// rgb:r/g/b
439    /// rgb:rr/gg/bb
440    /// rgb:rrr/ggg/bbb
441    /// rgb:rrrr/gggg/bbbb
442    /// ```
443    BackgroundColor = b'B',
444    /// Penetrate GNU Screen using DCS pass-through sequence
445    PenetrateScreen = b'P',
446    /// Read source images from stdin continuously
447    PipeInput = b'D',
448    /// Print debugging info
449    Verbose = b'v',
450    /// Print version and license info
451    Version = b'V',
452    /// Print a help message
453    Help = b'H',
454}
455
456pub type MallocFn = Option<unsafe extern "C" fn(size: usize) -> *mut c_void>;
457pub type CallocFn = Option<unsafe extern "C" fn(num_items: usize, size: usize) -> *mut c_void>;
458pub type ReallocFn = Option<unsafe extern "C" fn(object: *mut c_void, new_size: usize)
459                                                 -> *mut c_void>;
460pub type FreeFn = Option<unsafe extern "C" fn(object: *mut c_void)>;
461
462/// Can be passed to API functions to control allocation
463pub enum Allocator {}
464
465extern "C" {
466    /// Create a new allocator
467    pub fn sixel_allocator_new(ppallocator: *mut *mut Allocator,
468                               fn_malloc: MallocFn,
469                               fn_calloc: CallocFn,
470                               fn_realloc: ReallocFn,
471                               fn_free: FreeFn)
472                               -> Status;
473    pub fn sixel_allocator_ref(allocator: *mut Allocator);
474    pub fn sixel_allocator_unref(allocator: *mut Allocator);
475    pub fn sixel_allocator_malloc(allocator: *mut Allocator, n: usize) -> *mut c_void;
476    pub fn sixel_allocator_calloc(allocator: *mut Allocator,
477                                  nelm: usize,
478                                  elsize: usize)
479                                  -> *mut c_void;
480    pub fn sixel_allocator_realloc(allocator: *mut Allocator,
481                                   p: *mut c_void,
482                                   n: usize)
483                                   -> *mut c_void;
484    pub fn sixel_allocator_free(allocator: *mut Allocator, p: *mut c_void);
485}
486
487pub enum Output {}
488pub type WriteFn = ::std::option::Option<unsafe extern "C" fn(data: *mut c_char,
489                                                              size: c_int,
490                                                              priv_: *mut c_void)
491                                                              -> c_int>;
492extern "C" {
493    pub fn sixel_output_new(output: *mut *mut Output,
494                            fn_write: WriteFn,
495                            priv_: *mut c_void,
496                            allocator: *mut Allocator)
497                            -> Status;
498    pub fn sixel_output_create(fn_write: WriteFn, priv_: *mut c_void) -> *mut Output;
499    pub fn sixel_output_destroy(output: *mut Output);
500    pub fn sixel_output_ref(output: *mut Output);
501    pub fn sixel_output_unref(output: *mut Output);
502    pub fn sixel_output_get_8bit_availability(output: *mut Output) -> c_int;
503    pub fn sixel_output_set_8bit_availability(output: *mut Output, availability: CharacterSize);
504    // max value of `value` is 255
505    pub fn sixel_output_set_gri_arg_limit(output: *mut Output, value: c_int);
506    // penetrate acts like a bool
507    pub fn sixel_output_set_penetrate_multiplexer(output: *mut Output, penetrate: c_int);
508    pub fn sixel_output_set_skip_dcs_envelope(output: *mut Output, skip: c_int);
509    pub fn sixel_output_set_palette_type(output: *mut Output, palettetype: PaletteType);
510    pub fn sixel_output_set_encode_policy(output: *mut Output, encode_policy: EncodePolicy);
511}
512
513pub enum Dither {}
514extern "C" {
515    pub fn sixel_dither_new(ppdither: *mut *mut Dither,
516                            ncolors: c_int,
517                            allocator: *mut Allocator)
518                            -> Status;
519    pub fn sixel_dither_create(ncolors: c_int) -> *mut Dither;
520    pub fn sixel_dither_get(builtin_dither: BuiltinDither) -> *mut Dither;
521    pub fn sixel_dither_destroy(dither: *mut Dither);
522    pub fn sixel_dither_ref(dither: *mut Dither);
523    pub fn sixel_dither_unref(dither: *mut Dither);
524    pub fn sixel_dither_initialize(dither: *mut Dither,
525                                   data: *mut c_uchar,
526                                   width: c_int,
527                                   height: c_int,
528                                   pixelformat: PixelFormat,
529                                   method_for_largest: MethodForLargest,
530                                   method_for_rep: MethodForRepColor,
531                                   quality_mode: QualityMode)
532                                   -> Status;
533    pub fn sixel_dither_set_diffusion_type(dither: *mut Dither,
534                                           method_for_diffuse: DiffusionMethod);
535    pub fn sixel_dither_get_num_of_palette_colors(dither: *mut Dither) -> c_int;
536    pub fn sixel_dither_get_num_of_histogram_colors(dither: *mut Dither) -> c_int;
537    pub fn sixel_dither_get_num_of_histgram_colors(dither: *mut Dither) -> c_int;
538    pub fn sixel_dither_get_palette(dither: *mut Dither) -> *mut c_uchar;
539    pub fn sixel_dither_set_palette(dither: *mut Dither, palette: *mut c_uchar);
540    pub fn sixel_dither_set_complexion_score(dither: *mut Dither, score: c_int);
541    // `bodyonly` acts as a bool
542    pub fn sixel_dither_set_body_only(dither: *mut Dither, bodyonly: c_int);
543    // `do_opt` acts as a bool
544    pub fn sixel_dither_set_optimize_palette(dither: *mut Dither, do_opt: c_int);
545    pub fn sixel_dither_set_pixelformat(dither: *mut Dither, pixelformat: PixelFormat);
546    pub fn sixel_dither_set_transparent(dither: *mut Dither, transparent: c_int);
547}
548extern "C" {
549    // `depth` is unused
550    pub fn sixel_encode(pixels: *mut c_uchar,
551                        width: c_int,
552                        height: c_int,
553                        depth: c_int,
554                        dither: *mut Dither,
555                        context: *mut Output)
556                        -> Status;
557    // `ncolors` <= 256
558    pub fn sixel_decode_raw(p: *mut c_uchar,
559                            len: c_int,
560                            pixels: *mut *mut c_uchar,
561                            pwidth: *mut c_int,
562                            pheight: *mut c_int,
563                            palette: *mut *mut c_uchar,
564                            ncolors: *mut c_int,
565                            allocator: *mut Allocator)
566                            -> Status;
567    pub fn sixel_decode(sixels: *mut c_uchar,
568                        size: c_int,
569                        pixels: *mut *mut c_uchar,
570                        pwidth: *mut c_int,
571                        pheight: *mut c_int,
572                        palette: *mut *mut c_uchar,
573                        ncolors: *mut c_int,
574                        fn_malloc: MallocFn)
575                        -> Status;
576}
577extern "C" {
578    pub fn sixel_helper_set_additional_message(message: *const c_char);
579    pub fn sixel_helper_get_additional_message() -> *const c_char;
580    pub fn sixel_helper_format_error(status: Status) -> *const c_char;
581    pub fn sixel_helper_compute_depth(pixelformat: PixelFormat) -> c_int;
582    pub fn sixel_helper_normalize_pixelformat(dst: *mut c_uchar,
583                                              dst_pixelformat: *mut PixelFormat,
584                                              src: *const c_uchar,
585                                              src_pixelformat: PixelFormat,
586                                              width: c_int,
587                                              height: c_int)
588                                              -> Status;
589    pub fn sixel_helper_scale_image(dst: *mut c_uchar,
590                                    src: *const c_uchar,
591                                    srcw: c_int,
592                                    srch: c_int,
593                                    pixelformat: PixelFormat,
594                                    dstw: c_int,
595                                    dsth: c_int,
596                                    method_for_resampling: ResamplingMethod,
597                                    allocator: *mut Allocator)
598                                    -> Status;
599}
600
601pub enum Frame {}
602extern "C" {
603    pub fn sixel_frame_new(ppframe: *mut *mut Frame, allocator: *mut Allocator) -> Status;
604    pub fn sixel_frame_create() -> *mut Frame;
605    pub fn sixel_frame_ref(frame: *mut Frame);
606    pub fn sixel_frame_unref(frame: *mut Frame);
607    pub fn sixel_frame_init(frame: *mut Frame,
608                            pixels: *mut c_uchar,
609                            width: c_int,
610                            height: c_int,
611                            pixelformat: PixelFormat,
612                            palette: *mut c_uchar,
613                            ncolors: c_int)
614                            -> Status;
615    pub fn sixel_frame_get_pixels(frame: *mut Frame) -> *mut c_uchar;
616    pub fn sixel_frame_get_palette(frame: *mut Frame) -> *mut c_uchar;
617    pub fn sixel_frame_get_width(frame: *mut Frame) -> c_int;
618    pub fn sixel_frame_get_height(frame: *mut Frame) -> c_int;
619    pub fn sixel_frame_get_ncolors(frame: *mut Frame) -> c_int;
620    // Should return a PixelFormat
621    pub fn sixel_frame_get_pixelformat(frame: *mut Frame) -> c_int;
622    pub fn sixel_frame_get_transparent(frame: *mut Frame) -> c_int;
623    pub fn sixel_frame_get_multiframe(frame: *mut Frame) -> c_int;
624    pub fn sixel_frame_get_delay(frame: *mut Frame) -> c_int;
625    pub fn sixel_frame_get_frame_no(frame: *mut Frame) -> c_int;
626    pub fn sixel_frame_get_loop_no(frame: *mut Frame) -> c_int;
627    pub fn sixel_frame_strip_alpha(frame: *mut Frame, bgcolor: *mut c_uchar) -> c_int;
628    pub fn sixel_frame_resize(frame: *mut Frame,
629                              width: c_int,
630                              height: c_int,
631                              method_for_resampling: ResamplingMethod)
632                              -> Status;
633    pub fn sixel_frame_clip(frame: *mut Frame,
634                            x: c_int,
635                            y: c_int,
636                            width: c_int,
637                            height: c_int)
638                            -> Status;
639}
640
641pub type LoadImageFn = Option<unsafe extern "C" fn(frame: *mut Frame, context: *mut c_void)
642                                                   -> Status>;
643extern "C" {
644    pub fn sixel_helper_load_image_file(filename: *const c_char,
645                                        fstatic: c_int,
646                                        fuse_palette: c_int,
647                                        reqcolors: c_int,
648                                        bgcolor: *mut c_uchar,
649                                        loop_control: LoopMode,
650                                        fn_load: LoadImageFn,
651                                        finsecure: c_int,
652                                        cancel_flag: *const c_int,
653                                        context: *mut c_void,
654                                        allocator: *mut Allocator)
655                                        -> Status;
656    pub fn sixel_helper_write_image_file(data: *mut c_uchar,
657                                         width: c_int,
658                                         height: c_int,
659                                         palette: *mut c_uchar,
660                                         pixelformat: PixelFormat,
661                                         filename: *const c_char,
662                                         imageformat: ImageFormat,
663                                         allocator: *mut Allocator)
664                                         -> Status;
665}
666
667pub enum Encoder {}
668extern "C" {
669    pub fn sixel_encoder_new(ppencoder: *mut *mut Encoder, allocator: *mut Allocator) -> Status;
670    pub fn sixel_encoder_create() -> *mut Encoder;
671    pub fn sixel_encoder_ref(encoder: *mut Encoder);
672    pub fn sixel_encoder_unref(encoder: *mut Encoder);
673    pub fn sixel_encoder_set_cancel_flag(encoder: *mut Encoder, cancel_flag: *mut c_int) -> Status;
674    pub fn sixel_encoder_setopt(encoder: *mut Encoder,
675                                arg: Optflag,
676                                optarg: *const c_char)
677                                -> Status;
678    pub fn sixel_encoder_encode(encoder: *mut Encoder, filename: *const c_char) -> Status;
679    pub fn sixel_encoder_encode_bytes(encoder: *mut Encoder,
680                                      bytes: *mut c_uchar,
681                                      width: c_int,
682                                      height: c_int,
683                                      pixelformat: PixelFormat,
684                                      palette: *mut c_uchar,
685                                      ncolors: c_int)
686                                      -> Status;
687}
688
689pub enum Decoder {}
690extern "C" {
691    pub fn sixel_decoder_new(ppdecoder: *mut *mut Decoder, allocator: *mut Allocator) -> Status;
692    pub fn sixel_decoder_create() -> *mut Decoder;
693    pub fn sixel_decoder_ref(decoder: *mut Decoder);
694    pub fn sixel_decoder_unref(decoder: *mut Decoder);
695    pub fn sixel_decoder_setopt(decoder: *mut Decoder,
696                                arg: DecoderOptflag,
697                                optarg: *const c_char)
698                                -> Status;
699    pub fn sixel_decoder_decode(decoder: *mut Decoder) -> Status;
700}