Initial git import
[sxemacs] / src / ui / imgproc.h
1 /* Image processing aux functions header file
2    Copyright (C) 1998 Jareth Hein
3
4 This file is part of SXEmacs
5
6 SXEmacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 SXEmacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
18
19
20 #ifndef INCLUDED_imgproc_h_
21 #define INCLUDED_imgproc_h_
22
23 /* Synched up with: Not in FSF. */
24
25 /* Original author: Jareth Hein */
26
27 #define MAX_CMAP_SIZE   256
28 #define COLOR_DEPTH     8
29 #define MAX_COLOR       256
30
31 #define B_DEPTH         5       /* # bits/pixel to use */
32 #define B_LEN           (1L<<B_DEPTH)
33
34 #define C_DEPTH         2
35 #define C_LEN           (1L<<C_DEPTH)   /* # cells/color to use */
36
37 #define COLOR_SHIFT     (COLOR_DEPTH-B_DEPTH)
38
39 typedef struct colorbox {
40         struct colorbox *next, *prev;
41         int rmin, rmax;
42         int gmin, gmax;
43         int bmin, bmax;
44         int total;
45 } Colorbox;
46
47 typedef struct {
48         int num_ents;
49         int entries[MAX_CMAP_SIZE][2];
50 } C_cell;
51
52 typedef struct {
53         unsigned short rm[MAX_CMAP_SIZE], gm[MAX_CMAP_SIZE], bm[MAX_CMAP_SIZE]; /* map values */
54         int um[MAX_CMAP_SIZE];  /* usage counts for each mapentry */
55         int histogram[B_LEN][B_LEN][B_LEN];
56         int num_active_colors;
57         Colorbox *freeboxes;    /* used and freed internally */
58         Colorbox *usedboxes;    /* used and freed internally */
59         C_cell **ColorCells;    /* used and freed internally */
60 } quant_table;
61
62 #define QUANT_GET_COLOR(qt,r,g,b) (qt->histogram[r>>COLOR_SHIFT][g>>COLOR_SHIFT][b>>COLOR_SHIFT])
63
64 quant_table *build_EImage_quantable(unsigned char *eimage, int width,
65                                     int height, int num_colors);
66
67 #endif                          /* INCLUDED_imgproc_h_ */