1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef HISTOGRAM_HH
|
---|
10 | #define HISTOGRAM_HH
|
---|
11 |
|
---|
12 | #include "arch.hh"
|
---|
13 | #include "image/image.hh"
|
---|
14 |
|
---|
15 | class i4_file_class;
|
---|
16 |
|
---|
17 | class i4_histogram_class
|
---|
18 | {
|
---|
19 | public :
|
---|
20 | enum { HIST_SIZE=0x10000, // 16 bit histogram table
|
---|
21 | MAX_COLORS=256 };
|
---|
22 |
|
---|
23 | w16 reference[HIST_SIZE];
|
---|
24 | w32 counts[HIST_SIZE];
|
---|
25 | w32 tcolors; // total original colors in the histogram [length of reference]
|
---|
26 | w32 total_pixels; // total pixels accounted for in image (affected by counts_per_pixel)
|
---|
27 |
|
---|
28 |
|
---|
29 | i4_histogram_class();
|
---|
30 |
|
---|
31 | void increment_color(w16 color, // this is expected to be a 16 bit color (5 6 5)
|
---|
32 | w32 count)
|
---|
33 | {
|
---|
34 | if (!counts[color]) // is this an original color?
|
---|
35 | {
|
---|
36 | reference[tcolors]=color; // add this color to the reference list
|
---|
37 | tcolors++;
|
---|
38 | }
|
---|
39 | counts[color]+=count; // increment the counter for this color
|
---|
40 | total_pixels+=count; // count total pixels we've looked at
|
---|
41 | }
|
---|
42 |
|
---|
43 | void reset()
|
---|
44 | {
|
---|
45 | for (int i=0; i<tcolors; i++)
|
---|
46 | counts[reference[i]]=0;
|
---|
47 | tcolors=0;
|
---|
48 | total_pixels=0;
|
---|
49 | }
|
---|
50 |
|
---|
51 | void save(i4_file_class *fp);
|
---|
52 | void load(i4_file_class *fp);
|
---|
53 |
|
---|
54 | // counts_per_pixel can be used to give smaller images more emphasis
|
---|
55 | // I use this to give mip maps of original images more double emphasis
|
---|
56 | // right now only image's of type i4_image32 will work
|
---|
57 | void add_image_colors(i4_image_class *image, int counts_per_pixel=1);
|
---|
58 |
|
---|
59 | } ;
|
---|
60 |
|
---|
61 |
|
---|
62 |
|
---|
63 | #endif
|
---|