1 /***********************************************************************/
2 /* Open Visualization Data Explorer                                    */
3 /* (C) Copyright IBM Corp. 1989,1999                                   */
4 /* ALL RIGHTS RESERVED                                                 */
5 /* This code licensed under the                                        */
6 /*    "IBM PUBLIC LICENSE - Open Visualization Data Explorer"          */
7 /***********************************************************************/
8 
9 #include <dxconfig.h>
10 
11 #ifndef _QUANT_H_
12 #define _QUANT_H_
13 
14 typedef struct color *Color;
15 
16 struct color
17 {
18     unsigned char r, g, b;
19 };
20 
21 typedef struct treeNode *TreeNode;
22 
23 struct treeNode
24 {
25     int      leaf;
26     int      knt;
27     int	     r, g, b;
28     TreeNode kids[8];
29     TreeNode next;
30     TreeNode last;
31 };
32 
33 typedef struct treeNodeBuf *TreeNodeBuf;
34 
35 #define ALLOC 100
36 
37 struct treeNodeBuf
38 {
39     struct treeNode nodes[ALLOC];
40     TreeNodeBuf     nextbuf;
41     int             nextfree;
42 };
43 
44 #define BRANCH(color, depth, index)		 \
45 {						 \
46         int d = 7 - depth;			 \
47 	index = (((color->r >> d) & 0x1) << 0) + \
48 		(((color->g >> d) & 0x1) << 1) + \
49 		(((color->b >> d) & 0x1) << 2);	 \
50 }
51 
52 
53 TreeNode GetTreeNode();
54 void FreeNode( TreeNode );
55 void CleanupNodes();
56 TreeNode InsertTree( TreeNode, Color, int );
57 int SearchTree( TreeNode, Color, int );
58 int ReduceTree();
59 int CountLeaves( TreeNode, int * );
60 TreeNode CreateTree( Pointer, int, int, int );
61 TreeNode AddFieldToTree(TreeNode, Pointer, int, int, int );
62 Error CreateTable( TreeNode, Color, int, int * );
63 Error CreateQuantPixels(TreeNode, Pointer, unsigned char *, int, int );
64 
65 
66 #endif /* _QUANT_H_ */
67