gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-support/png2hicolorgb/src/hicolor/median.h
1 #ifndef __median_h__
2 #define __median_h__
3
4 #include "defines.h"
5
6
7 #define MAXNUMCOLORS 256
8
9 #define PRECISION_R 5
10 #define PRECISION_G 5
11 #define PRECISION_B 5
12
13 #define R_SCALE << 1
14 #define G_SCALE * 3
15 #define B_SCALE
16
17 #define HIST_R_ELEMS (1<<PRECISION_R)
18 #define HIST_G_ELEMS (1<<PRECISION_G)
19 #define HIST_B_ELEMS (1<<PRECISION_B)
20
21 #define MR HIST_G_ELEMS*HIST_B_ELEMS
22 #define MG HIST_B_ELEMS
23
24 #define BITS_IN_SAMPLE 8
25
26 #define R_SHIFT (BITS_IN_SAMPLE - PRECISION_R)
27 #define G_SHIFT (BITS_IN_SAMPLE - PRECISION_G)
28 #define B_SHIFT (BITS_IN_SAMPLE - PRECISION_B)
29
30 typedef struct _Color Color;
31 typedef struct _QuantizeObj QuantizeObj;
32 typedef void (*Pass_Func) (QuantizeObj *, unsigned char *, unsigned char *, long, long);
33 typedef unsigned long ColorFreq;
34
35 typedef ColorFreq *Histogram;
36
37
38 struct _Color
39 {
40 int red;
41 int green;
42 int blue;
43 };
44
45 typedef struct
46 {
47 int Rmin, Rmax; // The bounds of the box (inclusive); expressed as histogram indexes
48 int Gmin, Gmax;
49 int Bmin, Bmax;
50 int volume; // The volume (actually 2-norm) of the box
51 long colorcount; //The number of nonzero histogram cells within this box */
52 } mbox, *boxptr;
53
54
55
56
57
58 extern u8 Picture256[160*BUF_HEIGHT*3];
59 extern u8 QuantizedPalette[256][3];
60
61
62 void zero_histogram_rgb(void);
63 boxptr find_biggest_color_pop(boxptr boxlist,s32 numboxes);
64 boxptr find_biggest_volume(boxptr boxlist,s32 numboxes);
65 void update_box_rgb(boxptr boxp);
66 s32 median_cut_rgb(boxptr boxlist,s32 numboxes);
67 void compute_color_rgb(boxptr boxp,s32 icolor);
68 s32 find_nearby_colors(s32 minR,s32 minG,s32 minB,s32 colorlist[]);
69 void find_best_colors(s32 minR, s32 minG, s32 minB,s32 numcolors,s32 colorlist[],s32 bestcolor[]);
70 void fill_inverse_cmap_rgb(s32 R, s32 G, s32 B);
71 void median_cut_pass1_rgb(u8 *src,s32 width,s32 height);
72 s32 *init_error_limit(void);
73 void to_indexed(u8 *input,s32 dither,s32 width,s32 height);
74
75
76 #endif
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.