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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
|
/*
* bltImage.h --
*
* Copyright 1993-1998 Lucent Technologies, Inc.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
* granted, provided that the above copyright notice appear in all
* copies and that both that the copyright notice and warranty
* disclaimer appear in supporting documentation, and that the names
* of Lucent Technologies any of their entities not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission.
*
* Lucent Technologies disclaims all warranties with regard to this
* software, including all implied warranties of merchantability and
* fitness. In no event shall Lucent Technologies be liable for any
* special, indirect or consequential damages or any damages
* whatsoever resulting from loss of use, data or profits, whether in
* an action of contract, negligence or other tortuous action, arising
* out of or in connection with the use or performance of this
* software.
*/
#include <X11/Xutil.h>
#ifndef WIN32
#include <X11/Xproto.h>
#endif
#ifndef _BLT_IMAGE_H
#define _BLT_IMAGE_H
#define DIV255(i) ((((i) + 1) + (((i) + 1) >> 8) ) >> 8)
#define GAMMA (1.0)
#define ROTATE_0 0
#define ROTATE_90 1
#define ROTATE_180 2
#define ROTATE_270 3
/*
*----------------------------------------------------------------------
*
* Pix32 --
*
* A union representing either a pixel as a RGB triplet or a
* single word value.
*
*----------------------------------------------------------------------
*/
typedef union {
unsigned int value; /* Lookup table address */
struct RGBA {
unsigned char red; /* Red intensity 0..255 */
unsigned char green; /* Green intensity 0.255 */
unsigned char blue; /* Blue intensity 0..255 */
unsigned char alpha; /* Alpha-channel for compositing. 0..255 */
} rgba;
unsigned char channel[4];
} Pix32;
#define Red rgba.red
#define Blue rgba.blue
#define Green rgba.green
#define Alpha rgba.alpha
typedef struct {
XColor exact, best;
double error;
unsigned int freq;
int allocated;
int index;
} ColorInfo;
/*
*----------------------------------------------------------------------
*
* ColorTable --
*
* For colormap-ed visuals, this structure contains color lookup
* information needed to translate RGB triplets to pixel indices.
*
* This structure isn't needed for TrueColor or Monochrome visuals.
*
* DirectColor:
* Pixel values for each color channel
* StaticColor, PsuedoColor, StaticGray, and GrayScale:
* Red represents the 8-bit color. Green and Blue pixel
* values are unused.
*
*----------------------------------------------------------------------
*/
typedef struct ColorTableStruct {
double outputGamma; /* Gamma correction value */
Display *display; /* Display of colortable. Used to free
* colors allocated. */
XVisualInfo visualInfo; /* Visual information for window displaying
* the image. */
Colormap colorMap; /* Colormap used. This may be the default
* colormap, or an allocated private map. */
int flags;
unsigned int red[256], green[256], blue[256];
/* Array of allocated pixels in colormap */
ColorInfo colorInfo[256];
ColorInfo *sortedColors[256];
int nUsedColors, nFreeColors;
int nPixels; /* Number of colors in the quantized image */
unsigned long int pixelValues[256];
unsigned int *lut; /* Color lookup table. Used to collect
* frequencies of colors and later
* colormap indices */
} *ColorTable;
#define PRIVATE_COLORMAP 1
#define RGBIndex(r,g,b) (((r)<<10) + ((r)<<6) + (r) + ((g) << 5) + (g) + (b))
/*
*----------------------------------------------------------------------
*
* Blt_ColorImage --
*
* The structure below represents a color image. Each pixel
* occupies a 32-bit word of memory: one byte for each of the
* red, green, and blue color intensities, and another for
* alpha-channel image compositing (e.g. transparency).
*
*----------------------------------------------------------------------
*/
typedef struct ColorImage {
int width, height; /* Dimensions of the image */
Pix32 *bits; /* Array of pixels representing the image. */
} *Blt_ColorImage;
/*
* Blt_ColorImage is supposed to be an opaque type.
* Use the macros below to access its members.
*/
#define Blt_ColorImageHeight(c) ((c)->height)
#define Blt_ColorImageWidth(c) ((c)->width)
#define Blt_ColorImageBits(c) ((c)->bits)
#define Blt_ColorImagePixel(c, x, y) ((c)->bits + ((c)->width * (y)) + (x))
/*
*----------------------------------------------------------------------
*
* ResampleFilterProc --
*
* A function implementing a 1-D filter.
*
*----------------------------------------------------------------------
*/
typedef double (ResampleFilterProc) _ANSI_ARGS_((double value));
/*
*----------------------------------------------------------------------
*
* ResampleFilter --
*
* Contains information about a 1-D filter (its support and
* the procedure implementing the filter).
*
*----------------------------------------------------------------------
*/
typedef struct {
char *name; /* Name of the filter */
ResampleFilterProc *proc; /* 1-D filter procedure. */
double support; /* Width of 1-D filter */
} ResampleFilter;
extern ResampleFilter *bltBoxFilterPtr; /* The ubiquitous box filter */
/*
*----------------------------------------------------------------------
*
* Filter2D --
*
* Defines a convolution mask for a 2-D filter. Used to smooth or
* enhance images.
*
*----------------------------------------------------------------------
*/
typedef struct {
double support; /* Radius of filter */
double sum, scale; /* Sum of kernel */
double *kernel; /* Array of values (malloc-ed) representing
* the discrete 2-D filter. */
} Filter2D;
/* Prototypes of image routines */
extern void Blt_ColorImageToGreyscale _ANSI_ARGS_((Blt_ColorImage image));
extern void Blt_ColorImageToPhoto _ANSI_ARGS_((Blt_ColorImage image,
Tk_PhotoHandle photo));
extern Pixmap Blt_ColorImageToPixmap _ANSI_ARGS_((Tcl_Interp *interp,
Tk_Window tkwin, Blt_ColorImage image, ColorTable *colorTablePtr));
extern Blt_ColorImage Blt_ConvolveColorImage _ANSI_ARGS_((
Blt_ColorImage srcImage, Filter2D *filter));
extern Blt_ColorImage Blt_CreateColorImage _ANSI_ARGS_((int width,int height));
extern Blt_ColorImage Blt_DrawableToColorImage _ANSI_ARGS_((Tk_Window tkwin,
Drawable drawable, int x, int y, int width, int height,
double inputGamma));
extern int Blt_GetResampleFilter _ANSI_ARGS_((Tcl_Interp *interp,
char *filterName, ResampleFilter **filterPtrPtr));
extern void Blt_FreeColorImage _ANSI_ARGS_((Blt_ColorImage image));
#if HAVE_JPEG
extern Blt_ColorImage Blt_JPEGToColorImage _ANSI_ARGS_((Tcl_Interp *interp,
char *fileName));
#endif
extern Blt_ColorImage Blt_PhotoToColorImage _ANSI_ARGS_((
Tk_PhotoHandle photo));
extern Blt_ColorImage Blt_PhotoRegionToColorImage _ANSI_ARGS_((
Tk_PhotoHandle photo, int x, int y, int width, int height));
extern int Blt_TransColorImage _ANSI_ARGS_((Blt_ColorImage src,
Blt_ColorImage dest, Pix32 *color, int alpha, int flags));
extern int Blt_RecolorImage _ANSI_ARGS_((Blt_ColorImage src,
Blt_ColorImage dest, Pix32 *oldColor, Pix32 *newColor, int alpha));
extern int Blt_MergeColorImage _ANSI_ARGS_((Blt_ColorImage src,
Blt_ColorImage src2,
Blt_ColorImage dest, double opacity, double opacity2, Pix32 *withColor));
int Blt_ImageMergeInner _ANSI_ARGS_((Tcl_Interp *interp, char *srcName, char *src2Name,
char * destName, XColor *maskColor, int leaveMsg));
extern int Blt_QuantizeColorImage _ANSI_ARGS_((Blt_ColorImage src,
Blt_ColorImage dest, int nColors));
extern Blt_ColorImage Blt_ResampleColorImage _ANSI_ARGS_((Blt_ColorImage image,
int destWidth, int destHeight, ResampleFilter *horzFilterPtr,
ResampleFilter *vertFilterPtr));
extern void Blt_ResamplePhoto _ANSI_ARGS_((Tk_PhotoHandle srcPhoto,
int x, int y, int width, int height, Tk_PhotoHandle destPhoto,
ResampleFilter *horzFilterPtr, ResampleFilter *vertFilterPtr));
extern int Blt_BlurColorImage _ANSI_ARGS_((
Tk_PhotoHandle srcPhoto, Tk_PhotoHandle dstPhoto, int radius));
extern Blt_ColorImage Blt_ResizeColorImage _ANSI_ARGS_((Blt_ColorImage src,
int x, int y, int width, int height, int destWidth, int destHeight));
extern Blt_ColorImage Blt_ResizeColorSubimage _ANSI_ARGS_((Blt_ColorImage src,
int x, int y, int width, int height, int destWidth, int destHeight));
extern Blt_ColorImage Blt_RotateColorImage _ANSI_ARGS_((Blt_ColorImage image,
double theta));
extern void Blt_ResizePhoto _ANSI_ARGS_((Tk_PhotoHandle srcPhoto, int x, int y,
int width, int height, Tk_PhotoHandle destPhoto));
extern int Blt_SnapPhoto _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin,
Drawable drawable, int x, int y, int width, int height, int destWidth,
int destHeight, char *photoName, double inputGamma));
extern void Blt_ImageRegion _ANSI_ARGS_((Blt_ColorImage image,
Region2D *regionPtr));
Blt_ColorImage Blt_CopyColorImage _ANSI_ARGS_(( Blt_ColorImage src));
extern Region2D *Blt_ColorImageRegion _ANSI_ARGS_((Blt_ColorImage image,
Region2D *regionPtr));
extern Region2D *Blt_SetRegion _ANSI_ARGS_((int x, int y, int width,
int height, Region2D *regionPtr));
extern ColorTable Blt_CreateColorTable _ANSI_ARGS_((Tk_Window tkwin));
extern ColorTable Blt_DirectColorTable _ANSI_ARGS_((Tcl_Interp *interp,
Tk_Window tkwin, Blt_ColorImage image));
extern ColorTable Blt_PseudoColorTable _ANSI_ARGS_((Tcl_Interp *interp,
Tk_Window tkwin, Blt_ColorImage image));
extern void Blt_FreeColorTable _ANSI_ARGS_((ColorTable colorTable));
/* Missing routines from the Tk photo C API */
extern int Tk_ImageIsDeleted _ANSI_ARGS_((Tk_Image tkImage));
extern Tk_ImageMaster Tk_ImageGetMaster _ANSI_ARGS_((Tk_Image tkImage));
extern Tk_ImageType *Tk_ImageGetType _ANSI_ARGS_((Tk_Image tkImage));
extern Pixmap Tk_ImageGetPhotoPixmap _ANSI_ARGS_((Tk_Image photoImage));
extern GC Tk_ImageGetPhotoGC _ANSI_ARGS_((Tk_Image photoImage));
extern char *Blt_NameOfImage _ANSI_ARGS_((Tk_Image tkImage));
extern Tk_Image Blt_CreateTemporaryImage _ANSI_ARGS_((Tcl_Interp *interp,
Tk_Window tkwin, ClientData clientData));
extern int Blt_DestroyTemporaryImage _ANSI_ARGS_((Tcl_Interp *interp,
Tk_Image tkImage));
extern GC Blt_GetBitmapGC _ANSI_ARGS_((Tk_Window tkwin));
extern Pixmap Blt_PhotoImageMask _ANSI_ARGS_((Tk_Window tkwin,
Tk_PhotoImageBlock src));
extern Pixmap Blt_RotateBitmap _ANSI_ARGS_((Tk_Window tkwin, Pixmap bitmap,
int width, int height, double theta, int *widthPtr, int *heightPtr));
extern Pixmap Blt_ScaleBitmap _ANSI_ARGS_((Tk_Window tkwin, Pixmap srcBitmap,
int srcWidth, int srcHeight, int scaledWidth, int scaledHeight));
extern Pixmap Blt_ScaleRotateBitmapRegion _ANSI_ARGS_((Tk_Window tkwin,
Pixmap srcBitmap, unsigned int srcWidth, unsigned int srcHeight,
int regionX, int regionY, unsigned int regionWidth,
unsigned int regionHeight, unsigned int virtWidth,
unsigned int virtHeight, double theta));
typedef enum {MIRROR_X=1, MIRROR_Y=2, MIRROR_XY=3, MIRROR_TILE=4, MIRROR_OUTER=5, MIRROR_INNER=6} BltMirrorEnum;
extern int
Blt_ImageMirror(Tcl_Interp *interp, char *srcImg, char *dstImg, int flip, int halo);
#endif /*_BLT_IMAGE_H*/
|