]> git.imager.perl.org - imager.git/blob - datatypes.h
Made Makefile.PL run $Config{make} lib/Imager/Regops.pm so it exists
[imager.git] / datatypes.h
1 #ifndef _DATATYPES_H_
2 #define _DATATYPES_H_
3
4 #include "io.h"
5
6 #define MAXCHANNELS 4
7
8 typedef struct { unsigned char gray_color; } gray_color;
9 typedef struct { unsigned char r,g,b; } rgb_color;
10 typedef struct { unsigned char r,g,b,a; } rgba_color;
11 typedef struct { unsigned char c,m,y,k; } cmyk_color;
12
13 typedef int undef_int; /* special value to put in typemaps to retun undef on 0 and 1 on 1 */
14
15 typedef union {
16   gray_color gray;
17   rgb_color rgb;
18   rgba_color rgba;
19   cmyk_color cmyk;
20   unsigned char channel[MAXCHANNELS];
21   unsigned int ui;
22 } i_color;
23
24
25 struct _i_img {
26   int channels;
27   int xsize,ysize,bytes;
28   unsigned char *data;
29   unsigned int ch_mask;
30
31   int (*i_f_ppix) (struct _i_img *,int,int,i_color *); 
32   int (*i_f_gpix) (struct _i_img *,int,int,i_color *);
33   int (*i_f_plin) (struct _i_img *,int l, int r, int y, i_color *);
34   int (*i_f_glin) (struct _i_img *,int l, int r, int y, i_color *);
35   void *ext_data;
36 };
37
38 typedef struct _i_img i_img;
39
40 /* used for palette indices in some internal code (which might be 
41    exposed at some point
42 */
43 typedef unsigned char i_palidx;
44
45 /* Helper datatypes
46   The types in here so far are:
47
48   doubly linked bucket list - pretty efficient
49   octtree - no idea about goodness
50   
51   needed: hashes.
52
53 */
54
55
56
57
58
59 /* bitmap mask */
60
61 struct i_bitmap {
62   int xsize,ysize;
63   char *data;
64 };
65
66 struct i_bitmap* btm_new(int xsize,int ysize);
67 void btm_destroy(struct i_bitmap *btm);
68 int btm_test(struct i_bitmap *btm,int x,int y);
69 void btm_set(struct i_bitmap *btm,int x,int y);
70
71
72
73
74
75
76
77
78 /* Stack/Linked list */
79
80 struct llink {
81   struct llink *p,*n;
82   void *data;
83   int fill;             /* Number used in this link */
84 };
85
86 struct llist {
87   struct llink *h,*t;
88   int multip;           /* # of copies in a single chain  */
89   int ssize;            /* size of each small element     */
90   int count;           /* number of elements on the list */
91 };
92
93
94 /* Links */
95
96 struct llink *llink_new( struct llink* p,int size );
97 int  llist_llink_push( struct llist *lst, struct llink *lnk, void *data );
98
99 /* Lists */
100
101 struct llist *llist_new( int multip, int ssize );
102 void llist_destroy( struct llist *l );
103 void llist_push( struct llist *l, void *data );
104 void llist_dump( struct llist *l );
105 int llist_pop( struct llist *l,void *data );
106
107
108
109
110 /* Octtree */
111
112 struct octt {
113   struct octt *t[8]; 
114   int cnt;
115 };
116
117 struct octt *octt_new();
118 int octt_add(struct octt *ct,unsigned char r,unsigned char g,unsigned char b);
119 void octt_dump(struct octt *ct);
120 void octt_count(struct octt *ct,int *tot,int max,int *overflow);
121 void octt_delete(struct octt *ct);
122
123 #endif
124