aboutsummaryrefslogtreecommitdiffstats
path: root/liblss16_optimise.3
blob: 0a9d6e5fb60226972ef649422483e5e99a2cef78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
.TH LIBLSS16_OPTIMISE 3 LIBLSS16
.SH NAME
liblss16_optimise \- Optimise an image for best compression with LSS16

.SH SYNOPSIS
.nf
#include <liblss16.h>

struct liblss16_colour {
	uint8_t \fIr\fP;
	uint8_t \fIg\fP;
	uint8_t \fIb\fP;
};

struct liblss16_header {
	uint16_t \fIwidth\fP;
	uint16_t \fIheight\fP;
	struct liblss16_colour \fIcolour_map\fP[16];
};

void liblss16_optimise(struct liblss16_header *\fIheader\fP, uint8_t *\fIpixels\fP);
.fi
.PP
Link with
.IR -llss16 .

.SH DESCRIPTION
The
.BR liblss16_optimise ()
function reorders and deduplicates the colour palette
for an image so that it will compress optimally with LSS16.
.PP
.I header->width
shall be the width, in pixels, of the image.
.PP
.I header->height
shall be the height, in pixels, of the image.
.PP
.I header->colour_map
shall be the image's colour palette.
.PP
.I pixels
shall be a buffer of the colour index for
.I header->width*header->height
pixels. Ordered primarily from the top down
and secondarily from left to right. The colour
of a pixel encoded with the value
.I P
is determined by
.IR header->colour_map[P] .
Each
.B struct liblss16_colour
is encoded in sRGB with either 6 bits per channel
or 8 bits per channel
.RI ( .r
for the red channel,
.I .g
for the green channel, and
.I .b
for the blue channel).
.PP
Values in
.I pixels
must be 15 or less. The function will not validate the input.

.PP
The function will rewrite
.I header->colour_map
and
.IR pixels .

.SH RETURN VALUE
None.

.SH ERRORS
The
.BR liblss16_optimise ()
function cannot fail.

.SH SEE ALSO
.BR liblss16 (7)