| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
#include <X11/Xutil.h> |
| 26 |
#ifndef WIN32 |
| 27 |
#include <X11/Xproto.h> |
| 28 |
#endif |
| 29 |
|
| 30 |
#ifndef _BLT_IMAGE_H |
| 31 |
#define _BLT_IMAGE_H |
| 32 |
|
| 33 |
#define DIV255(i) ((((i) + 1) + (((i) + 1) >> 8) ) >> 8) |
| 34 |
|
| 35 |
#define GAMMA (1.0) |
| 36 |
|
| 37 |
#define ROTATE_0 0 |
| 38 |
#define ROTATE_90 1 |
| 39 |
#define ROTATE_180 2 |
| 40 |
#define ROTATE_270 3 |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
typedef union { |
| 53 |
unsigned int value; |
| 54 |
struct RGBA { |
| 55 |
unsigned char red; |
| 56 |
unsigned char green; |
| 57 |
unsigned char blue; |
| 58 |
unsigned char alpha; |
| 59 |
} rgba; |
| 60 |
unsigned char channel[4]; |
| 61 |
} Pix32; |
| 62 |
|
| 63 |
#define Red rgba.red |
| 64 |
#define Blue rgba.blue |
| 65 |
#define Green rgba.green |
| 66 |
#define Alpha rgba.alpha |
| 67 |
|
| 68 |
|
| 69 |
typedef struct { |
| 70 |
XColor exact, best; |
| 71 |
double error; |
| 72 |
unsigned int freq; |
| 73 |
int allocated; |
| 74 |
int index; |
| 75 |
} ColorInfo; |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
typedef struct ColorTableStruct { |
| 96 |
double outputGamma; |
| 97 |
Display *display; |
| 98 |
|
| 99 |
XVisualInfo visualInfo; |
| 100 |
|
| 101 |
Colormap colorMap; |
| 102 |
|
| 103 |
int flags; |
| 104 |
unsigned int red[256], green[256], blue[256]; |
| 105 |
|
| 106 |
|
| 107 |
ColorInfo colorInfo[256]; |
| 108 |
ColorInfo *sortedColors[256]; |
| 109 |
|
| 110 |
int nUsedColors, nFreeColors; |
| 111 |
int nPixels; |
| 112 |
unsigned long int pixelValues[256]; |
| 113 |
|
| 114 |
unsigned int *lut; |
| 115 |
|
| 116 |
|
| 117 |
} *ColorTable; |
| 118 |
|
| 119 |
#define PRIVATE_COLORMAP 1 |
| 120 |
#define RGBIndex(r,g,b) (((r)<<10) + ((r)<<6) + (r) + ((g) << 5) + (g) + (b)) |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
typedef struct ColorImage { |
| 135 |
int width, height; |
| 136 |
Pix32 *bits; |
| 137 |
} *Blt_ColorImage; |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
#define Blt_ColorImageHeight(c) ((c)->height) |
| 144 |
#define Blt_ColorImageWidth(c) ((c)->width) |
| 145 |
#define Blt_ColorImageBits(c) ((c)->bits) |
| 146 |
#define Blt_ColorImagePixel(c, x, y) ((c)->bits + ((c)->width * (y)) + (x)) |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
typedef double (ResampleFilterProc) _ANSI_ARGS_((double value)); |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
typedef struct { |
| 170 |
char *name; |
| 171 |
ResampleFilterProc *proc; |
| 172 |
double support; |
| 173 |
} ResampleFilter; |
| 174 |
|
| 175 |
extern ResampleFilter *bltBoxFilterPtr; |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
typedef struct { |
| 189 |
double support; |
| 190 |
double sum, scale; |
| 191 |
double *kernel; |
| 192 |
|
| 193 |
} Filter2D; |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
extern void Blt_ColorImageToGreyscale _ANSI_ARGS_((Blt_ColorImage image)); |
| 198 |
|
| 199 |
extern void Blt_ColorImageToPhoto _ANSI_ARGS_((Blt_ColorImage image, |
| 200 |
Tk_PhotoHandle photo)); |
| 201 |
|
| 202 |
extern Pixmap Blt_ColorImageToPixmap _ANSI_ARGS_((Tcl_Interp *interp, |
| 203 |
Tk_Window tkwin, Blt_ColorImage image, ColorTable *colorTablePtr)); |
| 204 |
|
| 205 |
extern Blt_ColorImage Blt_ConvolveColorImage _ANSI_ARGS_(( |
| 206 |
Blt_ColorImage srcImage, Filter2D *filter)); |
| 207 |
|
| 208 |
extern Blt_ColorImage Blt_CreateColorImage _ANSI_ARGS_((int width,int height)); |
| 209 |
|
| 210 |
extern Blt_ColorImage Blt_DrawableToColorImage _ANSI_ARGS_((Tk_Window tkwin, |
| 211 |
Drawable drawable, int x, int y, int width, int height, |
| 212 |
double inputGamma)); |
| 213 |
|
| 214 |
extern int Blt_GetResampleFilter _ANSI_ARGS_((Tcl_Interp *interp, |
| 215 |
char *filterName, ResampleFilter **filterPtrPtr)); |
| 216 |
|
| 217 |
extern void Blt_FreeColorImage _ANSI_ARGS_((Blt_ColorImage image)); |
| 218 |
|
| 219 |
#if HAVE_JPEG |
| 220 |
extern Blt_ColorImage Blt_JPEGToColorImage _ANSI_ARGS_((Tcl_Interp *interp, |
| 221 |
char *fileName)); |
| 222 |
#endif |
| 223 |
|
| 224 |
extern Blt_ColorImage Blt_PhotoToColorImage _ANSI_ARGS_(( |
| 225 |
Tk_PhotoHandle photo)); |
| 226 |
|
| 227 |
extern Blt_ColorImage Blt_PhotoRegionToColorImage _ANSI_ARGS_(( |
| 228 |
Tk_PhotoHandle photo, int x, int y, int width, int height)); |
| 229 |
|
| 230 |
extern int Blt_TransColorImage _ANSI_ARGS_((Blt_ColorImage src, |
| 231 |
Blt_ColorImage dest, Pix32 *color, int alpha, int flags)); |
| 232 |
|
| 233 |
extern int Blt_RecolorImage _ANSI_ARGS_((Blt_ColorImage src, |
| 234 |
Blt_ColorImage dest, Pix32 *oldColor, Pix32 *newColor, int alpha)); |
| 235 |
|
| 236 |
extern int Blt_MergeColorImage _ANSI_ARGS_((Blt_ColorImage src, |
| 237 |
Blt_ColorImage src2, |
| 238 |
Blt_ColorImage dest, double opacity, double opacity2, Pix32 *withColor)); |
| 239 |
|
| 240 |
int Blt_ImageMergeInner _ANSI_ARGS_((Tcl_Interp *interp, char *srcName, char *src2Name, |
| 241 |
char * destName, XColor *maskColor, int leaveMsg)); |
| 242 |
|
| 243 |
extern int Blt_QuantizeColorImage _ANSI_ARGS_((Blt_ColorImage src, |
| 244 |
Blt_ColorImage dest, int nColors)); |
| 245 |
|
| 246 |
extern Blt_ColorImage Blt_ResampleColorImage _ANSI_ARGS_((Blt_ColorImage image, |
| 247 |
int destWidth, int destHeight, ResampleFilter *horzFilterPtr, |
| 248 |
ResampleFilter *vertFilterPtr)); |
| 249 |
|
| 250 |
extern void Blt_ResamplePhoto _ANSI_ARGS_((Tk_PhotoHandle srcPhoto, |
| 251 |
int x, int y, int width, int height, Tk_PhotoHandle destPhoto, |
| 252 |
ResampleFilter *horzFilterPtr, ResampleFilter *vertFilterPtr)); |
| 253 |
|
| 254 |
|
| 255 |
extern int Blt_BlurColorImage _ANSI_ARGS_(( |
| 256 |
Tk_PhotoHandle srcPhoto, Tk_PhotoHandle dstPhoto, int radius)); |
| 257 |
|
| 258 |
extern Blt_ColorImage Blt_ResizeColorImage _ANSI_ARGS_((Blt_ColorImage src, |
| 259 |
int x, int y, int width, int height, int destWidth, int destHeight)); |
| 260 |
|
| 261 |
extern Blt_ColorImage Blt_ResizeColorSubimage _ANSI_ARGS_((Blt_ColorImage src, |
| 262 |
int x, int y, int width, int height, int destWidth, int destHeight)); |
| 263 |
|
| 264 |
extern Blt_ColorImage Blt_RotateColorImage _ANSI_ARGS_((Blt_ColorImage image, |
| 265 |
double theta)); |
| 266 |
|
| 267 |
extern void Blt_ResizePhoto _ANSI_ARGS_((Tk_PhotoHandle srcPhoto, int x, int y, |
| 268 |
int width, int height, Tk_PhotoHandle destPhoto)); |
| 269 |
|
| 270 |
extern int Blt_SnapPhoto _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin, |
| 271 |
Drawable drawable, int x, int y, int width, int height, int destWidth, |
| 272 |
int destHeight, char *photoName, double inputGamma)); |
| 273 |
|
| 274 |
extern void Blt_ImageRegion _ANSI_ARGS_((Blt_ColorImage image, |
| 275 |
Region2D *regionPtr)); |
| 276 |
|
| 277 |
Blt_ColorImage Blt_CopyColorImage _ANSI_ARGS_(( Blt_ColorImage src)); |
| 278 |
|
| 279 |
extern Region2D *Blt_ColorImageRegion _ANSI_ARGS_((Blt_ColorImage image, |
| 280 |
Region2D *regionPtr)); |
| 281 |
|
| 282 |
extern Region2D *Blt_SetRegion _ANSI_ARGS_((int x, int y, int width, |
| 283 |
int height, Region2D *regionPtr)); |
| 284 |
|
| 285 |
extern ColorTable Blt_CreateColorTable _ANSI_ARGS_((Tk_Window tkwin)); |
| 286 |
|
| 287 |
extern ColorTable Blt_DirectColorTable _ANSI_ARGS_((Tcl_Interp *interp, |
| 288 |
Tk_Window tkwin, Blt_ColorImage image)); |
| 289 |
|
| 290 |
extern ColorTable Blt_PseudoColorTable _ANSI_ARGS_((Tcl_Interp *interp, |
| 291 |
Tk_Window tkwin, Blt_ColorImage image)); |
| 292 |
|
| 293 |
extern void Blt_FreeColorTable _ANSI_ARGS_((ColorTable colorTable)); |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
extern int Tk_ImageIsDeleted _ANSI_ARGS_((Tk_Image tkImage)); |
| 298 |
extern Tk_ImageMaster Tk_ImageGetMaster _ANSI_ARGS_((Tk_Image tkImage)); |
| 299 |
extern Tk_ImageType *Tk_ImageGetType _ANSI_ARGS_((Tk_Image tkImage)); |
| 300 |
extern Pixmap Tk_ImageGetPhotoPixmap _ANSI_ARGS_((Tk_Image photoImage)); |
| 301 |
extern GC Tk_ImageGetPhotoGC _ANSI_ARGS_((Tk_Image photoImage)); |
| 302 |
|
| 303 |
extern char *Blt_NameOfImage _ANSI_ARGS_((Tk_Image tkImage)); |
| 304 |
extern Tk_Image Blt_CreateTemporaryImage _ANSI_ARGS_((Tcl_Interp *interp, |
| 305 |
Tk_Window tkwin, ClientData clientData)); |
| 306 |
extern int Blt_DestroyTemporaryImage _ANSI_ARGS_((Tcl_Interp *interp, |
| 307 |
Tk_Image tkImage)); |
| 308 |
|
| 309 |
extern GC Blt_GetBitmapGC _ANSI_ARGS_((Tk_Window tkwin)); |
| 310 |
extern Pixmap Blt_PhotoImageMask _ANSI_ARGS_((Tk_Window tkwin, |
| 311 |
Tk_PhotoImageBlock src)); |
| 312 |
|
| 313 |
extern Pixmap Blt_RotateBitmap _ANSI_ARGS_((Tk_Window tkwin, Pixmap bitmap, |
| 314 |
int width, int height, double theta, int *widthPtr, int *heightPtr)); |
| 315 |
|
| 316 |
extern Pixmap Blt_ScaleBitmap _ANSI_ARGS_((Tk_Window tkwin, Pixmap srcBitmap, |
| 317 |
int srcWidth, int srcHeight, int scaledWidth, int scaledHeight)); |
| 318 |
|
| 319 |
extern Pixmap Blt_ScaleRotateBitmapRegion _ANSI_ARGS_((Tk_Window tkwin, |
| 320 |
Pixmap srcBitmap, unsigned int srcWidth, unsigned int srcHeight, |
| 321 |
int regionX, int regionY, unsigned int regionWidth, |
| 322 |
unsigned int regionHeight, unsigned int virtWidth, |
| 323 |
unsigned int virtHeight, double theta)); |
| 324 |
|
| 325 |
typedef enum {MIRROR_X=1, MIRROR_Y=2, MIRROR_XY=3, MIRROR_TILE=4, MIRROR_OUTER=5, MIRROR_INNER=6} BltMirrorEnum; |
| 326 |
|
| 327 |
extern int |
| 328 |
Blt_ImageMirror(Tcl_Interp *interp, char *srcImg, char *dstImg, int flip, int halo); |
| 329 |
|
| 330 |
|
| 331 |
#endif |