Krita Source Code Documentation
Loading...
Searching...
No Matches
palette.h
Go to the documentation of this file.
1/* Palette-manipulation functions functions for xcftools
2 *
3 * This file was written by Henning Makholm <henning@makholm.net>
4 * It is hereby in the public domain.
5 *
6 * In jurisdictions that do not recognise grants of copyright to the
7 * public domain: I, the author and (presumably, in those jurisdictions)
8 * copyright holder, hereby permit anyone to distribute and use this code,
9 * in source code or binary form, with or without modifications. This
10 * permission is world-wide and irrevocable.
11 *
12 * Of course, I will not be liable for any errors or shortcomings in the
13 * code, since I give it away without asking any compenstations.
14 *
15 * If you use or distribute this code, I would appreciate receiving
16 * credit for writing it, in whichever way you find proper and customary.
17 */
18
19#ifndef PALETTE_H
20#define PALETTE_H
21
22#include "xcftools.h"
23#include "pixels.h"
24
25#define MAX_PALETTE 256
26extern rgba palette[MAX_PALETTE] ;
27extern unsigned paletteSize ;
28
29typedef uint8_t index_t ;
30
31void init_palette_hash(void);
32
33/* lookup_or_intern() returns a negative number if there is no room
34 * for the color in the palette.
35 */
36int lookup_or_intern(rgba color);
37
38/* palettify_row will convert a row of 'rgba' values into a packed row
39 * of 'uint8_t' indces. If it succeeds without running out of colormap
40 * entries, it returns nonzero. On the other hand if it does run out
41 * of colormap entries it returns zero _and_ undoes the conversions
42 * already done, so that the row is still a full row of 'rgba' values
43 * afterwards.
44 */
45int palettify_row(rgba *row,unsigned ncols);
46
47/* palettify_rows is like palettify_rows, but works on several
48 * rows at a time.
49 */
50int palettify_rows(rgba *rows[],unsigned ncols,unsigned nlines);
51
52#endif /* PALETTE_H */
unsigned paletteSize
Definition palette.c:34
void init_palette_hash(void)
Definition palette.c:40
int palettify_row(rgba *row, unsigned ncols)
Definition palette.c:80
int lookup_or_intern(rgba color)
Definition palette.c:51
#define MAX_PALETTE
Definition palette.h:25
uint8_t index_t
Definition palette.h:29
rgba palette[MAX_PALETTE]
Definition palette.c:35
int palettify_rows(rgba *rows[], unsigned ncols, unsigned nlines)
Definition palette.c:97
uint32_t rgba
Definition pixels.h:44