4 * Copyright 1993-1998 Lucent Technologies, Inc.
6 * Permission to use, copy, modify, and distribute this software and
7 * its documentation for any purpose and without fee is hereby
8 * granted, provided that the above copyright notice appear in all
9 * copies and that both that the copyright notice and warranty
10 * disclaimer appear in supporting documentation, and that the names
11 * of Lucent Technologies any of their entities not be used in
12 * advertising or publicity pertaining to distribution of the software
13 * without specific, written prior permission.
15 * Lucent Technologies disclaims all warranties with regard to this
16 * software, including all implied warranties of merchantability and
17 * fitness. In no event shall Lucent Technologies be liable for any
18 * special, indirect or consequential damages or any damages
19 * whatsoever resulting from loss of use, data or profits, whether in
20 * an action of contract, negligence or other tortuous action, arising
21 * out of or in connection with the use or performance of this
25 #include <X11/Xutil.h>
27 #include <X11/Xproto.h>
33 #define DIV255(i) ((((i) + 1) + (((i) + 1) >> 8) ) >> 8)
43 *----------------------------------------------------------------------
47 * A union representing either a pixel as a RGB triplet or a
50 *----------------------------------------------------------------------
53 unsigned int value; /* Lookup table address */
55 unsigned char red; /* Red intensity 0..255 */
56 unsigned char green; /* Green intensity 0.255 */
57 unsigned char blue; /* Blue intensity 0..255 */
58 unsigned char alpha; /* Alpha-channel for compositing. 0..255 */
60 unsigned char channel[4];
64 #define Blue rgba.blue
65 #define Green rgba.green
66 #define Alpha rgba.alpha
78 *----------------------------------------------------------------------
82 * For colormap-ed visuals, this structure contains color lookup
83 * information needed to translate RGB triplets to pixel indices.
85 * This structure isn't needed for TrueColor or Monochrome visuals.
88 * Pixel values for each color channel
89 * StaticColor, PsuedoColor, StaticGray, and GrayScale:
90 * Red represents the 8-bit color. Green and Blue pixel
93 *----------------------------------------------------------------------
95 typedef struct ColorTableStruct {
96 double outputGamma; /* Gamma correction value */
97 Display *display; /* Display of colortable. Used to free
98 * colors allocated. */
99 XVisualInfo visualInfo; /* Visual information for window displaying
101 Colormap colorMap; /* Colormap used. This may be the default
102 * colormap, or an allocated private map. */
104 unsigned int red[256], green[256], blue[256];
106 /* Array of allocated pixels in colormap */
107 ColorInfo colorInfo[256];
108 ColorInfo *sortedColors[256];
110 int nUsedColors, nFreeColors;
111 int nPixels; /* Number of colors in the quantized image */
112 unsigned long int pixelValues[256];
114 unsigned int *lut; /* Color lookup table. Used to collect
115 * frequencies of colors and later
116 * colormap indices */
119 #define PRIVATE_COLORMAP 1
120 #define RGBIndex(r,g,b) (((r)<<10) + ((r)<<6) + (r) + ((g) << 5) + (g) + (b))
123 *----------------------------------------------------------------------
127 * The structure below represents a color image. Each pixel
128 * occupies a 32-bit word of memory: one byte for each of the
129 * red, green, and blue color intensities, and another for
130 * alpha-channel image compositing (e.g. transparency).
132 *----------------------------------------------------------------------
134 typedef struct ColorImage {
135 int width, height; /* Dimensions of the image */
136 Pix32 *bits; /* Array of pixels representing the image. */
140 * Blt_ColorImage is supposed to be an opaque type.
141 * Use the macros below to access its members.
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))
149 *----------------------------------------------------------------------
151 * ResampleFilterProc --
153 * A function implementing a 1-D filter.
155 *----------------------------------------------------------------------
157 typedef double (ResampleFilterProc) _ANSI_ARGS_((double value));
160 *----------------------------------------------------------------------
164 * Contains information about a 1-D filter (its support and
165 * the procedure implementing the filter).
167 *----------------------------------------------------------------------
170 char *name; /* Name of the filter */
171 ResampleFilterProc *proc; /* 1-D filter procedure. */
172 double support; /* Width of 1-D filter */
175 extern ResampleFilter *bltBoxFilterPtr; /* The ubiquitous box filter */
179 *----------------------------------------------------------------------
183 * Defines a convolution mask for a 2-D filter. Used to smooth or
186 *----------------------------------------------------------------------
189 double support; /* Radius of filter */
190 double sum, scale; /* Sum of kernel */
191 double *kernel; /* Array of values (malloc-ed) representing
192 * the discrete 2-D filter. */
195 /* Prototypes of image routines */
197 extern void Blt_ColorImageToGreyscale _ANSI_ARGS_((Blt_ColorImage image));
199 extern void Blt_ColorImageToPhoto _ANSI_ARGS_((Blt_ColorImage image,
200 Tk_PhotoHandle photo));
202 extern Pixmap Blt_ColorImageToPixmap _ANSI_ARGS_((Tcl_Interp *interp,
203 Tk_Window tkwin, Blt_ColorImage image, ColorTable *colorTablePtr));
205 extern Blt_ColorImage Blt_ConvolveColorImage _ANSI_ARGS_((
206 Blt_ColorImage srcImage, Filter2D *filter));
208 extern Blt_ColorImage Blt_CreateColorImage _ANSI_ARGS_((int width,int height));
210 extern Blt_ColorImage Blt_DrawableToColorImage _ANSI_ARGS_((Tk_Window tkwin,
211 Drawable drawable, int x, int y, int width, int height,
214 extern int Blt_GetResampleFilter _ANSI_ARGS_((Tcl_Interp *interp,
215 char *filterName, ResampleFilter **filterPtrPtr));
217 extern void Blt_FreeColorImage _ANSI_ARGS_((Blt_ColorImage image));
220 extern Blt_ColorImage Blt_JPEGToColorImage _ANSI_ARGS_((Tcl_Interp *interp,
224 extern Blt_ColorImage Blt_PhotoToColorImage _ANSI_ARGS_((
225 Tk_PhotoHandle photo));
227 extern Blt_ColorImage Blt_PhotoRegionToColorImage _ANSI_ARGS_((
228 Tk_PhotoHandle photo, int x, int y, int width, int height));
230 extern int Blt_TransColorImage _ANSI_ARGS_((Blt_ColorImage src,
231 Blt_ColorImage dest, Pix32 *color, int alpha, int flags));
233 extern int Blt_RecolorImage _ANSI_ARGS_((Blt_ColorImage src,
234 Blt_ColorImage dest, Pix32 *oldColor, Pix32 *newColor, int alpha));
236 extern int Blt_MergeColorImage _ANSI_ARGS_((Blt_ColorImage src,
238 Blt_ColorImage dest, double opacity, double opacity2, Pix32 *withColor));
240 int Blt_ImageMergeInner _ANSI_ARGS_((Tcl_Interp *interp, char *srcName, char *src2Name,
241 char * destName, XColor *maskColor, int leaveMsg));
243 extern int Blt_QuantizeColorImage _ANSI_ARGS_((Blt_ColorImage src,
244 Blt_ColorImage dest, int nColors));
246 extern Blt_ColorImage Blt_ResampleColorImage _ANSI_ARGS_((Blt_ColorImage image,
247 int destWidth, int destHeight, ResampleFilter *horzFilterPtr,
248 ResampleFilter *vertFilterPtr));
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));
255 extern int Blt_BlurColorImage _ANSI_ARGS_((
256 Tk_PhotoHandle srcPhoto, Tk_PhotoHandle dstPhoto, int radius));
258 extern Blt_ColorImage Blt_ResizeColorImage _ANSI_ARGS_((Blt_ColorImage src,
259 int x, int y, int width, int height, int destWidth, int destHeight));
261 extern Blt_ColorImage Blt_ResizeColorSubimage _ANSI_ARGS_((Blt_ColorImage src,
262 int x, int y, int width, int height, int destWidth, int destHeight));
264 extern Blt_ColorImage Blt_RotateColorImage _ANSI_ARGS_((Blt_ColorImage image,
267 extern void Blt_ResizePhoto _ANSI_ARGS_((Tk_PhotoHandle srcPhoto, int x, int y,
268 int width, int height, Tk_PhotoHandle destPhoto));
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));
274 extern void Blt_ImageRegion _ANSI_ARGS_((Blt_ColorImage image,
275 Region2D *regionPtr));
277 Blt_ColorImage Blt_CopyColorImage _ANSI_ARGS_(( Blt_ColorImage src));
279 extern Region2D *Blt_ColorImageRegion _ANSI_ARGS_((Blt_ColorImage image,
280 Region2D *regionPtr));
282 extern Region2D *Blt_SetRegion _ANSI_ARGS_((int x, int y, int width,
283 int height, Region2D *regionPtr));
285 extern ColorTable Blt_CreateColorTable _ANSI_ARGS_((Tk_Window tkwin));
287 extern ColorTable Blt_DirectColorTable _ANSI_ARGS_((Tcl_Interp *interp,
288 Tk_Window tkwin, Blt_ColorImage image));
290 extern ColorTable Blt_PseudoColorTable _ANSI_ARGS_((Tcl_Interp *interp,
291 Tk_Window tkwin, Blt_ColorImage image));
293 extern void Blt_FreeColorTable _ANSI_ARGS_((ColorTable colorTable));
295 /* Missing routines from the Tk photo C API */
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));
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,
309 extern GC Blt_GetBitmapGC _ANSI_ARGS_((Tk_Window tkwin));
310 extern Pixmap Blt_PhotoImageMask _ANSI_ARGS_((Tk_Window tkwin,
311 Tk_PhotoImageBlock src));
313 extern Pixmap Blt_RotateBitmap _ANSI_ARGS_((Tk_Window tkwin, Pixmap bitmap,
314 int width, int height, double theta, int *widthPtr, int *heightPtr));
316 extern Pixmap Blt_ScaleBitmap _ANSI_ARGS_((Tk_Window tkwin, Pixmap srcBitmap,
317 int srcWidth, int srcHeight, int scaledWidth, int scaledHeight));
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));
325 typedef enum {MIRROR_X=1, MIRROR_Y=2, MIRROR_XY=3, MIRROR_TILE=4, MIRROR_OUTER=5, MIRROR_INNER=6} BltMirrorEnum;
328 Blt_ImageMirror(Tcl_Interp *interp, char *srcImg, char *dstImg, int flip, int halo);
331 #endif /*_BLT_IMAGE_H*/