1 #ifdef HAVE_CONFIG_H 2 #include "config.h" 3 #endif 4 5 #include <stdio.h> 6 #include <unistd.h> 7 #include <stdlib.h> 8 #include <math.h> 9 #include <ctype.h> 10 #include <time.h> 11 #include <netinet/in.h> 12 #ifdef HAVE_SYS_IPC_H 13 #include <sys/ipc.h> 14 #endif 15 #ifdef HAVE_SYS_SHM_H 16 #include <sys/shm.h> 17 #endif 18 #include <sys/time.h> 19 #include <sys/types.h> 20 21 #ifdef _HAVE_STRING_H 22 #include <string.h> 23 #elif _HAVE_STRINGS_H 24 #include <strings.h> 25 #endif 26 27 #include <X11/Xlib.h> 28 #include <X11/Xutil.h> 29 #include <X11/Xatom.h> 30 #include <X11/Xos.h> 31 #ifdef HAVE_X11_EXTENSIONS_XSHM_H 32 #include <X11/extensions/XShm.h> 33 #endif 34 #include <X11/extensions/shape.h> 35 #include <X11/cursorfont.h> 36 37 #include <png.h> 38 #include <jpeglib.h> 39 40 #define BYTE_ORD_24_RGB 0 41 #define BYTE_ORD_24_RBG 1 42 #define BYTE_ORD_24_BRG 2 43 #define BYTE_ORD_24_BGR 3 44 #define BYTE_ORD_24_GRB 4 45 #define BYTE_ORD_24_GBR 5 46 47 struct image_cache 48 { 49 char *file; 50 ImlibImage *im; 51 int refnum; 52 char dirty; 53 struct image_cache *prev; 54 struct image_cache *next; 55 }; 56 57 struct pixmap_cache 58 { 59 ImlibImage *im; 60 char *file; 61 char dirty; 62 int width, height; 63 Pixmap pmap; 64 Pixmap shape_mask; 65 XImage *xim; 66 XImage *sxim; 67 int refnum; 68 struct pixmap_cache *prev; 69 struct pixmap_cache *next; 70 }; 71 72 73 int index_best_color_match(ImlibData * id, int *r, int *g, int *b); 74 void dirty_pixmaps(ImlibData * id, ImlibImage * im); 75 void dirty_images(ImlibData * id, ImlibImage * im); 76 void find_pixmap(ImlibData * id, ImlibImage * im, int width, int height, Pixmap * pmap, Pixmap * mask); 77 ImlibImage *find_image(ImlibData * id, const char *file); 78 void free_pixmappmap(ImlibData * id, Pixmap pmap); 79 void free_image(ImlibData * id, ImlibImage * im); 80 void flush_image(ImlibData * id, ImlibImage * im); 81 void add_image(ImlibData * id, ImlibImage * im, const char *file); 82 void add_pixmap(ImlibData * id, ImlibImage * im, int width, int height, XImage * xim, XImage * sxim); 83 void clean_caches(ImlibData * id); 84 void nullify_image(ImlibData * id, ImlibImage * im); 85 86 int ispng(FILE *f); 87 88 void calc_map_tables(ImlibData * id, ImlibImage * im); 89 90 void _PaletteAlloc(ImlibData * id, int num, const int *cols); 91 92 FILE *open_helper(const char *, const char *, const char *); 93 int close_helper(FILE *); 94 95 #define INDEX_RGB(r,g,b) id->fast_rgb[(r<<10)|(g<<5)|(b)] 96 #define COLOR_INDEX(i) id->palette[i].pixel 97 #define COLOR_RGB(r,g,b) id->palette[INDEX_RGB(r,g,b)].pixel 98 #define ERROR_RED(rr,i) rr-id->palette[i].r 99 #define ERROR_GRN(gg,i) gg-id->palette[i].g 100 #define ERROR_BLU(bb,i) bb-id->palette[i].b 101 102 #define DITHER_ERROR(Der1,Der2,Dex,Der,Deg,Deb) \ 103 do {\ 104 ter=&(Der1[Dex]);\ 105 (*ter)+=(Der*7)>>4;ter++;\ 106 (*ter)+=(Deg*7)>>4;ter++;\ 107 (*ter)+=(Deb*7)>>4;\ 108 ter=&(Der2[Dex-6]);\ 109 (*ter)+=(Der*3)>>4;ter++;\ 110 (*ter)+=(Deg*3)>>4;ter++;\ 111 (*ter)+=(Deb*3)>>4;ter++;\ 112 (*ter)+=(Der*5)>>4;ter++;\ 113 (*ter)+=(Deg*5)>>4;ter++;\ 114 (*ter)+=(Deb*5)>>4;ter++;\ 115 (*ter)+=Der>>4;ter++;\ 116 (*ter)+=Deg>>4;ter++;\ 117 (*ter)+=Deb>>4; \ 118 } while (0) 119