1 /* Image processing aux functions header file
2 Copyright (C) 1998 Jareth Hein
4 This file is part of SXEmacs
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.
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.
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/>. */
20 #ifndef INCLUDED_imgproc_h_
21 #define INCLUDED_imgproc_h_
23 /* Synched up with: Not in FSF. */
25 /* Original author: Jareth Hein */
27 #define MAX_CMAP_SIZE 256
31 #define B_DEPTH 5 /* # bits/pixel to use */
32 #define B_LEN (1L<<B_DEPTH)
35 #define C_LEN (1L<<C_DEPTH) /* # cells/color to use */
37 #define COLOR_SHIFT (COLOR_DEPTH-B_DEPTH)
38 #define COLOR_MASK (B_LEN-1)
40 typedef struct colorbox {
41 struct colorbox *next, *prev;
50 int entries[MAX_CMAP_SIZE][2];
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 */
63 #define QUANT_GET_COLOR(qt,r,g,b) (qt->histogram[r>>COLOR_SHIFT][g>>COLOR_SHIFT][b>>COLOR_SHIFT])
65 quant_table *build_EImage_quantable(unsigned char *eimage, int width,
66 int height, int num_colors);
68 #endif /* INCLUDED_imgproc_h_ */