annotate src/imgproc.h @ 269:b2472a1930f2 r20-5b33

Import from CVS: tag r20-5b33
author cvs
date Mon, 13 Aug 2007 10:27:19 +0200
parents 8efd647ea9ca
children 74fd4e045ea6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
1 /* Image processing aux functions header file
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
2 Copyright (C) 1998 Jareth Hein
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
3
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
4 This file is a part of XEmacs
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
5
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
9 later version.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
10
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
14 for more details.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
15
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
20
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
22
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
23 /* Original author: Jareth Hein */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
24
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
25 #define MAX_CMAP_SIZE 256
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
26 #define COLOR_DEPTH 8
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
27 #define MAX_COLOR 256
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
28
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
29 #define B_DEPTH 5 /* # bits/pixel to use */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
30 #define B_LEN (1L<<B_DEPTH)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
31
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
32 #define C_DEPTH 2
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
33 #define C_LEN (1L<<C_DEPTH) /* # cells/color to use */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
34
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
35 #define COLOR_SHIFT (COLOR_DEPTH-B_DEPTH)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
36
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
37 typedef struct colorbox {
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
38 struct colorbox *next, *prev;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
39 int rmin, rmax;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
40 int gmin, gmax;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
41 int bmin, bmax;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
42 int total;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
43 } Colorbox;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
44
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
45 typedef struct {
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
46 int num_ents;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
47 int entries[MAX_CMAP_SIZE][2];
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
48 } C_cell;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
49
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
50 typedef struct {
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
51 unsigned short rm[MAX_CMAP_SIZE], gm[MAX_CMAP_SIZE], bm[MAX_CMAP_SIZE]; /* map values */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
52 int um[MAX_CMAP_SIZE]; /* usage counts for each mapentry */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
53 int histogram[B_LEN][B_LEN][B_LEN];
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
54 int num_active_colors;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
55 Colorbox *freeboxes; /* used and freed internally */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
56 Colorbox *usedboxes; /* used and freed internally */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
57 C_cell **ColorCells; /* used and freed internally */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
58 } quant_table;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
59
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
60 #define QUANT_GET_COLOR(qt,r,g,b) (qt->histogram[r>>COLOR_SHIFT][g>>COLOR_SHIFT][b>>COLOR_SHIFT])
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
61
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 265
diff changeset
62 quant_table *build_EImage_quantable(unsigned char *eimage, int width, int height, int num_colors);