blob: e8b95eb0605c8ad5f5919b410c01bddf16d83251 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
int
libquanta_palette_size(size_t ncolours, size_t nchannels, size_t *size_out)
{
if (!ncolours || !nchannels) {
errno = EINVAL;
return -1;
}
if (ncolours > (SIZE_MAX - PALETTE_BASE_SIZE) / PALETTE_VALUE_SIZE / nchannels) {
errno = EOVERFLOW;
return -1;
}
if (size_out)
*size_out = PALETTE_BASE_SIZE + ncolours * nchannels * PALETTE_VALUE_SIZE;
return 0;
}
|