You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creates a new SIXEL image. The optional `fillColor` (default black) is used to fill
8
9
"holey pixels" with a background color during pixel transfer in `toImageData`.
9
10
10
11
-`width: number`
11
-
Pixel width of the image. Updates during `write`.
12
+
Pixel width of the image. Updates during `write`. Other than stated in the SIXEL specification (DEC STD 070)
13
+
a width from raster attributes takes precedence, thus if a SIXEL data stream contains raster attributes
14
+
with a valid horizontal extend, width will always be set to this value, even for half transmitted images.
15
+
Also overlong sixel bands (a row of 6 vertical pixels) will be stripped to the raster attribute width.
16
+
(band data beyond width is not accessible anymore later on). If no raster attributes were transmitted
17
+
(used in earlier SIXEL variant) width will be set to the longest sixel band width found.
12
18
13
19
-`height: number`
14
-
Pixel height of the image. Updates during `write`.
20
+
Pixel height of the image. Updates during `write`. Height is either set from a valid vertical extend in
21
+
raster attributes, or grows with the number of sixel bands found in the data stream (number of bands * 6).
22
+
Raster attributes again have precedence over number of bands (band data beyond height is not
23
+
accessible anymore later on, also see `width`).
15
24
16
25
-`fillColor: RGBA8888`
17
-
Number respresenting the background fill color. The number depends on endianess of the architecture,
18
-
create it with `toRGBA8888(r, g, b, a)`.
26
+
Number respresenting the background fill color. A value of 0 will leave background pixels untouched.
27
+
The number depends on endianess of the architecture, create it with `toRGBA8888(r, g, b, a)`.
19
28
20
29
-`write(data: UintTypedArray, start: number = 0, end: number = data.length): void`
21
-
Writes SIXEL bytes to the image and updates the image data. This is done as a stream,
22
-
therefore it is possible to grab partly transmitted images (see browser example).
23
-
`data` can be any array like type with single bytes per index position.
30
+
Decodes SIXEL bytes and updates the image data. This is done as a stream,
31
+
therefore it is possible to grab partly transmitted images (see "Simulate slow chunks" in browser example).
32
+
`data` can be any array like type with single byte values per index position.
33
+
Note: Normally SIXEL data is embedded in a DCS escape sequence. To properly handle the full sequence with introducer
34
+
and finalizer you should to use an escape sequence parser (like `node-ansiparser` or the parser found in `xterm.js`).
35
+
The `write` method of `SixelImage` is only meant for the data part
36
+
(also see example `node_example_decode_full_sequence.js`).
24
37
25
38
-`writeString(data: string, start: number = 0, end: number = data.length): void`
26
39
Same as `write` but with string data instead. For better performance use `write`.
27
40
28
41
-`toImageData(target: Uint8ClampedArray, width: number, height: number, dx: number = 0, dy: number = 0, sx: number = 0, sy: number = 0, swidth: number = this.width, sheight: number = this.height, fillColor: RGBA8888 = this.fillColor): Uint8ClampedArray`
29
-
Write pixel data to pixel array `target`. A pixel array can be obtained from `ImageData.data`, e.g. from a canvas.
42
+
Writes pixel data to pixel array `target`. A pixel array can be obtained from `ImageData.data`, e.g. from a canvas.
30
43
`width` and `height` must contain the full dimension of the target. Use `dx`, `dy` (offset in target) and
31
44
`sx`, `sy` (offset in source) and `swidth`, `sheight` (area in source) for cropping/clipping. `fillColor` has the same
32
45
meaning as in the constructor, explicit setting it to 0 will leave non encoded pixels unaltered (pixels, that were not colored in the SIXEL data). This can be used for a transparency like effect (background/previous pixel value will remain). Returns the altered `target`.
Encodes image data as chunks of SIXEL bytes. `cb` will be called multiple times the SIXEL data in `chunk` until all image data was transmitted. `chunk` is borrowed, thus the data should be copied/written right away.
48
+
Encodes image data as chunks of SIXEL bytes. `cb` will be called multiple times with SIXEL data in `chunk` until all image data was transmitted. `chunk` is borrowed, thus the data should be copied/written right away.
36
49
Note: The output contains only the SIXEL image data (no escape sequence introducer / finalizer).
37
50
38
51
-`toSixelString(): string`
@@ -45,7 +58,8 @@ The library provides a class `SixelImage` with the following properties:
45
58
of `data`. Since SIXEL is a palette based image format, `palette` should contain the used colors in `data`.
46
59
If no palette was given the colors will fallback to a 16 colors palette derived from VT340. This is most
47
60
likely unwanted, also to avoid poor results in general use proper quantization/dithering and palette creation
48
-
before creating the SIXEL image. See `node_example_encode.js` for an example usage in conjunction with `rgbquant`.
61
+
before creating the SIXEL image. See `node_example_encode.js` for an example usage in conjunction with `rgbquant`.
62
+
For transparency only an alpha value of 0 will be respected as fully transparent, other alpha values are set to fully opaque (255). Transparent pixels will be colored by the terminal later on depending on the `backgroundSelect` setting of the introducer.
49
63
Note: Some terminals have strict palette limitations (e.g. xterm is bound to 16 colors only in VT340 mode).
50
64
51
65
-`static introducer(backgroundSelect: number = 0): string`
@@ -54,30 +68,30 @@ The library provides a class `SixelImage` with the following properties:
54
68
`backgroundSelect` is a hint for the terminal how to deal with uncolored pixels:
Converts the native color to an array of [r, g, b, a].
72
86
73
87
### Installation
74
88
Install the library with `npm install sixel`.
75
89
76
-
### Demos and examples
90
+
### Examples and browser demo
77
91
See the example files for decoding/encoding in nodejs. Note that the examples and the browser demo are not part
78
92
of the npm package, clone the repo and run `npm install` if you want to see them in action.
79
93
80
-
Decoding can also be tested in the browser with`npm start` under `localhost:8080`.
94
+
Decoding can also be tested in the browser after`npm start` under `localhost:8080`.
81
95
82
96
### Status
83
97
Currently alpha, tests are yet to come.
@@ -86,3 +100,7 @@ Currently alpha, tests are yet to come.
86
100
- tests
87
101
- optimizations
88
102
- more docs
103
+
104
+
### References
105
+
106
+
While being quite common in the DEC ecosystem in the 80s (even used for printer protocols), SIXEL references are very limited these days. The closest to a specification we have can be found in the Video Systems Reference Manual ([DEC STD 070](http://www.bitsavers.org/pdf/dec/standards/EL-SM070-00_DEC_STD_070_Video_Systems_Reference_Manual_Dec91.pdf#page=908), p. 908-933). Also see [Sixel Graphics](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) on vt100.net, which gives a quick overview. For implementation this old usenet article "[All About SIXELs](https://www.digiater.nl/openvms/decus/vax90b1/krypton-nasa/all-about-sixels.text)" was very helpful.
0 commit comments