irc-bitmap/README.md

59 lines
2.8 KiB
Markdown
Raw Permalink Normal View History

2019-01-11 21:14:23 +00:00
# irc-bitmap
2019-01-11 21:36:59 +00:00
A format for sending IRC bitmaps inline.
## Format
The format string shall be (in Python syntax) `r'<i([^-]+)-([^-]*-)(.*)'`.
2019-01-11 21:36:59 +00:00
The first capture group shall be a format. The currently recognized formats are `gb`, `r16`, and `r85`, though any format can be used. A program SHOULD gracefully report and exit on an unknown or unsupported format. The identifier of a format may not include a hyphen (dash).
2019-01-11 21:36:59 +00:00
The second capture group (optional) shall be known as the header and its syntax shall be defined by the format, but if present it MUST contain exactly one hypen and it must be the last character in the header.
2019-01-11 21:36:59 +00:00
The third capture group contains the image data, shall be known as the payload, and is defined by the format.
2019-01-11 21:36:59 +00:00
2019-01-11 21:57:45 +00:00
Upon receiving a message containing the part, a compliant client MAY take steps to attempt a conversion to PNG or similar, or display the image inline. A thread with timeout CAN and SHOULD be used.
While there is no theoretical limit to the size of the image you can send, you are bound by any message length limits your server sets, as the entire part MUST fit in one message.
2019-01-11 21:36:59 +00:00
## Recognized formats
### `gb` - GameBoy 2BPP 4-shade monochrome
For an explanation of the format, see [here](http://www.huderlem.com/demos/gameboy2bpp.html).
The header has this syntax: `r'(\d+).(\d+)-'`. The first and second capture groups specify the width and height in 8x8 tiles.
2019-01-11 21:57:45 +00:00
The payload is a hexadecimal representation of the image data. It has this syntax: `r'([0-9A-Fa-f]+)'`.
2019-01-11 21:57:45 +00:00
2019-01-11 21:36:59 +00:00
Example line: `<igb-1.1-FF007EFF858189839385A58BC9977EFF>`
Results in:
![Pokemon Red window](https://ttm.sh/qX.png)
### `r16` - Raw arbitrary bitmaps, hexadecimal-encoded
2019-01-11 21:36:59 +00:00
The header has this syntax: `r'(\d+).(\d+).(\d+)-'`. The first and second capture groups specify the width and height of the image and the third group specifies the bitdepth.
2019-01-11 21:36:59 +00:00
The payload is a hexadecimal representation of the image data. It has this syntax: `r'([0-9A-Fa-f]+)'`.
8x8, monochrome
Example line: `<irawhex-8.8.1-FF818181818181FF>`
Results in:
![box](https://ttm.sh/qy.png)
### `ra85` - Raw arbitrary bitmaps, (Adobe) ascii85-encoded
The header has this syntax: `r'(\d+).(\d+).(\d+)-'`. The first and second capture groups specify the width and height of the image and the third group specifies the bitdepth.
The payload is an (Adobe) ascii85-encoded representation of the image data. It has this syntax: `r'(<~[!-uz]+~>)'`.
8x8, monochrome
See https://en.wikipedia.org/wiki/Ascii85#Example_for_Ascii85 for the encoding. See `ruby-ascii85` package in Debian for an implementation. TODO: see https://www.dcode.fr/ascii-85-encoding for a non-Adobe implementation that will save at least four bytes.
Example line: `<ira85-8.8.1-<~?t'(dJUrB'Jc>~>`
2019-01-11 21:36:59 +00:00
Results in:
![box](https://ttm.sh/qy.png)