Kitty Graphics Protocol in OCaml
terminal graphics ocaml
1(** Data Compression 2 3 Specifies compression applied to image data before transmission. 4 5 {2 Protocol Details} 6 7 Compression is specified via the [o] key in the control data: 8 - No [o] key means no compression 9 - [o=z] means zlib (RFC 1950 DEFLATE) compression 10 11 Compression is applied to the raw pixel/PNG data {i before} base64 12 encoding. The terminal decompresses after base64 decoding. 13 14 {2 When to Use Compression} 15 16 Zlib compression is beneficial for: 17 - Large images with repetitive patterns 18 - Screenshots and UI graphics 19 - Images with large solid color regions 20 21 It may not help (or could increase size) for: 22 - Already-compressed PNG data 23 - Photographic images with high entropy 24 - Very small images (compression overhead) 25 26 {2 PNG with Compression} 27 28 When using both [{`Png}] format and [{`Zlib}] compression, the [size] 29 parameter must be specified with the original (uncompressed) PNG size. 30 The terminal needs this to allocate the correct buffer for decompression. *) 31 32type t = [ `None | `Zlib ] 33(** Compression options. 34 35 - [`None] - Raw uncompressed data. No [o=] key is sent. 36 - [`Zlib] - RFC 1950 zlib/DEFLATE compression. Data is compressed 37 before base64 encoding and decompressed by the terminal. *) 38 39val to_char : t -> char option 40(** Convert to protocol character. 41 42 Returns [None] for [`None] (no key sent), or [Some 'z'] for [`Zlib]. 43 When [Some c] is returned, [o=c] is added to the control data. *)