]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | #ifdef _HAVE_STRING_H |
2 | #include <string.h> | |
3 | #elif _HAVE_STRINGS_H | |
4 | #include <strings.h> | |
5 | #endif | |
6 | ||
7 | #ifndef CONVERT_PATH | |
8 | #define CONVERT_PATH "/usr/local/bin" | |
9 | #endif | |
10 | ||
11 | #ifndef NETPBM_PATH | |
12 | #define NETPBM_PATH "/usr/local/bin" | |
13 | #endif | |
14 | ||
15 | #ifndef CJPEG_PROG | |
16 | #define CJPEG_PROG "/usr/bin/cjpeg" | |
17 | #endif | |
18 | ||
19 | #include <stdio.h> | |
20 | #include <unistd.h> | |
21 | #include <stdlib.h> | |
22 | #include <math.h> | |
23 | #include <ctype.h> | |
24 | #include <time.h> | |
25 | #include <netinet/in.h> | |
26 | #include <sys/ipc.h> | |
27 | #include <sys/shm.h> | |
28 | #include <sys/time.h> | |
29 | #include <sys/types.h> | |
30 | ||
31 | #ifdef _HAVE_STRING_H | |
32 | #include <string.h> | |
33 | #elif _HAVE_STRINGS_H | |
34 | #include <strings.h> | |
35 | #endif | |
36 | ||
37 | #include <X11/Xlib.h> | |
38 | #include <X11/Xutil.h> | |
39 | #include <X11/Xatom.h> | |
40 | #include <X11/Xos.h> | |
41 | #include <X11/extensions/XShm.h> | |
42 | #include <X11/extensions/shape.h> | |
43 | #include <X11/cursorfont.h> | |
44 | #include <gdk/gdkprivate.h> | |
45 | ||
46 | #ifdef HAVE_LIBJPEG | |
47 | #include <jpeglib.h> | |
48 | #endif | |
49 | #ifdef HAVE_LIBPNG | |
50 | #include <png.h> | |
51 | #endif | |
52 | #ifdef HAVE_LIBTIFF | |
53 | #include <tiffio.h> | |
54 | #endif | |
55 | #ifdef HAVE_LIBGIF | |
56 | #include <gif_lib.h> | |
57 | #endif | |
58 | ||
59 | #define BYTE_ORD_24_RGB 0 | |
60 | #define BYTE_ORD_24_RBG 1 | |
61 | #define BYTE_ORD_24_BRG 2 | |
62 | #define BYTE_ORD_24_BGR 3 | |
63 | #define BYTE_ORD_24_GRB 4 | |
64 | #define BYTE_ORD_24_GBR 5 | |
65 | ||
66 | struct image_cache | |
67 | { | |
68 | gchar *file; | |
69 | GdkImlibImage *im; | |
70 | gint refnum; | |
71 | gchar dirty; | |
72 | struct image_cache *prev; | |
73 | struct image_cache *next; | |
74 | }; | |
75 | ||
76 | struct pixmap_cache | |
77 | { | |
78 | GdkImlibImage *im; | |
79 | gchar *file; | |
80 | gchar dirty; | |
81 | gint width, height; | |
82 | GdkPixmap *pmap; | |
83 | GdkBitmap *shape_mask; | |
84 | XImage *xim, *sxim; | |
85 | gint refnum; | |
86 | struct pixmap_cache *prev; | |
87 | struct pixmap_cache *next; | |
88 | }; | |
89 | ||
90 | typedef struct _xdata | |
91 | { | |
92 | Display *disp; | |
93 | gint screen; | |
94 | Window root; | |
95 | Visual *visual; | |
96 | gint depth; | |
97 | gint render_depth; | |
98 | Colormap root_cmap; | |
99 | gchar shm; | |
100 | gchar shmp; | |
101 | gint shm_event; | |
102 | XImage *last_xim; | |
103 | XImage *last_sxim; | |
104 | XShmSegmentInfo last_shminfo; | |
105 | XShmSegmentInfo last_sshminfo; | |
106 | Window base_window; | |
107 | GdkWindow *gdk_win; | |
108 | GdkColormap *gdk_cmap; | |
109 | } | |
110 | Xdata; | |
111 | ||
112 | typedef struct _imlibdata | |
113 | { | |
114 | gint num_colors; | |
115 | GdkImlibColor *palette; | |
116 | GdkImlibColor *palette_orig; | |
117 | unsigned char *fast_rgb; | |
118 | gint *fast_err; | |
119 | gint *fast_erg; | |
120 | gint *fast_erb; | |
121 | gint render_type; | |
122 | gint max_shm; | |
123 | Xdata x; | |
124 | gint byte_order; | |
125 | struct _cache | |
126 | { | |
127 | gchar on_image; | |
128 | gint size_image; | |
129 | gint num_image; | |
130 | gint used_image; | |
131 | struct image_cache *image; | |
132 | gchar on_pixmap; | |
133 | gint size_pixmap; | |
134 | gint num_pixmap; | |
135 | gint used_pixmap; | |
136 | struct pixmap_cache *pixmap; | |
137 | } | |
138 | cache; | |
139 | gchar fastrend; | |
140 | gchar hiq; | |
141 | GdkImlibColorModifier mod, rmod, gmod, bmod; | |
142 | unsigned char rmap[256], gmap[256], bmap[256]; | |
143 | gchar fallback; | |
144 | gchar ordered_dither; | |
145 | } | |
146 | ImlibData; | |
147 | ||
148 | extern ImlibData *id; | |
149 | ||
150 | gint gindex_best_color_match(gint * r, gint * g, gint * b); | |
151 | ||
152 | void gdirty_pixmaps(GdkImlibImage * im); | |
153 | void gdirty_images(GdkImlibImage * im); | |
154 | void gfind_pixmap(GdkImlibImage * im, int width, int height, GdkPixmap ** pmap, GdkBitmap ** mask); | |
155 | GdkImlibImage *gfind_image(char *file); | |
156 | void gfree_pixmappmap(GdkPixmap * pmap); | |
157 | void gfree_image(GdkImlibImage * im); | |
158 | void gflush_image(GdkImlibImage * im); | |
159 | void gadd_image(GdkImlibImage * im, char *file); | |
160 | void gadd_pixmap(GdkImlibImage * im, int width, int height, XImage * xim, XImage * sxim); | |
161 | void gclean_caches(); | |
162 | void gnullify_image(GdkImlibImage * im); | |
163 | ||
164 | /* char *g_SplitID(char *file); */ | |
165 | char *g_GetExtension(char *file); | |
166 | ||
167 | #ifdef HAVE_LIBJPEG | |
168 | unsigned char *g_LoadJPEG(FILE * f, int *w, int *h); | |
169 | ||
170 | #endif /* HAVE_LIBJPEG */ | |
171 | #ifdef HAVE_LIBPNG | |
172 | unsigned char *g_LoadPNG(FILE * f, int *w, int *h, int *t); | |
173 | ||
174 | #endif /* HAVE_LIBPNG */ | |
175 | #ifdef HAVE_LIBTIFF | |
176 | unsigned char *g_LoadTIFF(char *f, int *w, int *h, int *t); | |
177 | ||
178 | #endif /* HAVE_LIBTIFF */ | |
179 | #ifdef HAVE_LIBGIF | |
180 | unsigned char *g_LoadGIF(char *f, int *w, int *h, int *t); | |
181 | ||
182 | #endif /* HAVE_LIBGIF */ | |
183 | unsigned char *g_LoadXPM(char *f, int *w, int *h, int *t); | |
184 | unsigned char *g_LoadPPM(FILE * f, int *w, int *h); | |
185 | ||
186 | /* | |
187 | static int gispnm(char *file); | |
188 | static int gisjpeg(char *file); | |
189 | static int gispng(char *file); | |
190 | static int gistiff(char *file); | |
191 | static int giseim(char *file); | |
192 | static int gisgif(char *file); | |
193 | static int gisxpm(char *file); | |
194 | */ | |
195 | ||
196 | GdkPixmap *gdk_imlib_pixmap_foreign_new(gint width, gint height, gint depth, Pixmap pmap); | |
197 | ||
198 | void gcalc_map_tables(GdkImlibImage * im); | |
199 | ||
200 | void g_PaletteAlloc(int num, int *cols); | |
201 | ||
202 | FILE *open_helper(const char *, const char *, const char *); | |
203 | int close_helper(FILE *); | |
204 | ||
205 | #define INDEX_RGB(r,g,b) id->fast_rgb[(r<<10)|(g<<5)|(b)] | |
206 | #define COLOR_INDEX(i) id->palette[i].pixel | |
207 | #define COLOR_RGB(r,g,b) id->palette[INDEX_RGB(r,g,b)].pixel | |
208 | #define ERROR_RED(rr,i) rr-id->palette[i].r; | |
209 | #define ERROR_GRN(gg,i) gg-id->palette[i].g; | |
210 | #define ERROR_BLU(bb,i) bb-id->palette[i].b; | |
211 | ||
212 | #define DITHER_ERROR(Der1,Der2,Dex,Der,Deg,Deb) \ | |
213 | ter=&(Der1[Dex]);\ | |
214 | (*ter)+=(Der*7)>>4;ter++;\ | |
215 | (*ter)+=(Deg*7)>>4;ter++;\ | |
216 | (*ter)+=(Deb*7)>>4;\ | |
217 | ter=&(Der2[Dex-6]);\ | |
218 | (*ter)+=(Der*3)>>4;ter++;\ | |
219 | (*ter)+=(Deg*3)>>4;ter++;\ | |
220 | (*ter)+=(Deb*3)>>4;ter++;\ | |
221 | (*ter)+=(Der*5)>>4;ter++;\ | |
222 | (*ter)+=(Deg*5)>>4;ter++;\ | |
223 | (*ter)+=(Deb*5)>>4;ter++;\ | |
224 | (*ter)+=Der>>4;ter++;\ | |
225 | (*ter)+=Deg>>4;ter++;\ | |
226 | (*ter)+=Deb>>4; |