Page:
hosho_inflate
Pages
Control Functions
Embedding the Widget
Home
Keyboard Mouse and Paste
Overview
Pictures
Shell Integration
The Host Functions
The Widget in Use
Themes
Writing a Host
_sidebar
home
hosho
hosho_bidi
hosho_inflate
hosho_input
hosho_parser
hosho_pseudoterminal
hosho_screen
hosho_sixel
hosho_terminal
hosho_text
hosho_theme
hosho_width
No results
1
hosho_inflate
liquibyte edited this page 2026-11-19 16:23:30 -06:00
Table of Contents
hosho_inflate.h
Inflate: Data Compressed with zlib, Made Whole Again.
Copyright (c) 2016-2026 Michael Grey (liquibyte) liquibyte@gmail.com SPDX-License-Identifier: Artistic-2.0 Distributed under the Artistic License 2.0; see LICENSE for terms.
The Kitty graphics protocol lets a program compress a picture's pixels with zlib. This reads such data.
Features:
- The zlib stream of RFC 1950 with the deflate data of RFC 1951: stored blocks, fixed codes and dynamic codes
- The Adler-32 check at the stream's end
Internal design notes:
- Written from the two RFCs; it needs only libc
- It reads one bit at a time through the code lengths: simple, and fast enough for a picture
- The result is not larger than
HOSHO_INFLATE_LIMIT
#include "hosho_inflate.h"
Constants: HOSHO_INFLATE_LIMIT
Functions: hosho_inflate
Constants
HOSHO_INFLATE_LIMIT
#define HOSHO_INFLATE_LIMIT (64u << 20)
The most bytes a result has: a picture of 4096 by 4096 pixels with four bytes each.
Functions
hosho_inflate
uint8_t *hosho_inflate(const uint8_t *data, size_t length, size_t *result_length);
Make compressed data whole.
| Parameter | Description |
|---|---|
data |
A zlib stream |
length |
Its bytes |
result_length |
Gets the number of bytes of the result |
Returns: The bytes from malloc(), which the caller must free(); NULL when the data is not correct, the result is too large or memory ran out
Hosho API
The whole library
From bytes to a screen
For the host that shows it
The program