Build Fix -- compatibility issue with newer autoconf
[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 #define COLOR_MASK      (B_LEN-1)
39
40 typedef struct colorbox {
41         struct colorbox *next, *prev;
42         int rmin, rmax;
43         int gmin, gmax;
44         int bmin, bmax;
45         int total;
46 } Colorbox;
47
48 typedef struct {
49         int num_ents;
50         int entries[MAX_CMAP_SIZE][2];
51 } C_cell;
52
53 typedef struct {
54         unsigned short rm[MAX_CMAP_SIZE], gm[MAX_CMAP_SIZE], bm[MAX_CMAP_SIZE]; /* map values */
55         int um[MAX_CMAP_SIZE];  /* usage counts for each mapentry */
56         int histogram[B_LEN][B_LEN][B_LEN];
57         int num_active_colors;
58         Colorbox *freeboxes;    /* used and freed internally */
59         Colorbox *usedboxes;    /* used and freed internally */
60         C_cell **ColorCells;    /* used and freed internally */
61 } quant_table;
62
63 #define QUANT_GET_COLOR(qt,r,g,b) (qt->histogram[r>>COLOR_SHIFT][g>>COLOR_SHIFT][b>>COLOR_SHIFT])
64
65 quant_table *build_EImage_quantable(unsigned char *eimage, int width,
66                                     int height, int num_colors);
67
68 #endif                          /* INCLUDED_imgproc_h_ */