source: trunk/kitgen/8.x/blt/generic/bltImage.h@ 199

Last change on this file since 199 was 175, checked in by demin, 12 years ago

initial commit

File size: 10.2 KB
RevLine 
[175]1/*
2 * bltImage.h --
3 *
4 * Copyright 1993-1998 Lucent Technologies, Inc.
5 *
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.
14 *
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
22 * software.
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 * Pix32 --
46 *
47 * A union representing either a pixel as a RGB triplet or a
48 * single word value.
49 *
50 *----------------------------------------------------------------------
51 */
52typedef union {
53 unsigned int value; /* Lookup table address */
54 struct RGBA {
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 */
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
69typedef 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 * ColorTable --
82 *
83 * For colormap-ed visuals, this structure contains color lookup
84 * information needed to translate RGB triplets to pixel indices.
85 *
86 * This structure isn't needed for TrueColor or Monochrome visuals.
87 *
88 * DirectColor:
89 * Pixel values for each color channel
90 * StaticColor, PsuedoColor, StaticGray, and GrayScale:
91 * Red represents the 8-bit color. Green and Blue pixel
92 * values are unused.
93 *
94 *----------------------------------------------------------------------
95 */
96typedef struct ColorTableStruct {
97 double outputGamma; /* Gamma correction value */
98 Display *display; /* Display of colortable. Used to free
99 * colors allocated. */
100 XVisualInfo visualInfo; /* Visual information for window displaying
101 * the image. */
102 Colormap colorMap; /* Colormap used. This may be the default
103 * colormap, or an allocated private map. */
104 int flags;
105 unsigned int red[256], green[256], blue[256];
106
107 /* Array of allocated pixels in colormap */
108 ColorInfo colorInfo[256];
109 ColorInfo *sortedColors[256];
110
111 int nUsedColors, nFreeColors;
112 int nPixels; /* Number of colors in the quantized image */
113 unsigned long int pixelValues[256];
114
115 unsigned int *lut; /* Color lookup table. Used to collect
116 * frequencies of colors and later
117 * colormap indices */
118} *ColorTable;
119
120#define PRIVATE_COLORMAP 1
121#define RGBIndex(r,g,b) (((r)<<10) + ((r)<<6) + (r) + ((g) << 5) + (g) + (b))
122
123/*
124 *----------------------------------------------------------------------
125 *
126 * Blt_ColorImage --
127 *
128 * The structure below represents a color image. Each pixel
129 * occupies a 32-bit word of memory: one byte for each of the
130 * red, green, and blue color intensities, and another for
131 * alpha-channel image compositing (e.g. transparency).
132 *
133 *----------------------------------------------------------------------
134 */
135typedef struct ColorImage {
136 int width, height; /* Dimensions of the image */
137 Pix32 *bits; /* Array of pixels representing the image. */
138} *Blt_ColorImage;
139
140/*
141 * Blt_ColorImage is supposed to be an opaque type.
142 * Use the macros below to access its members.
143 */
144#define Blt_ColorImageHeight(c) ((c)->height)
145#define Blt_ColorImageWidth(c) ((c)->width)
146#define Blt_ColorImageBits(c) ((c)->bits)
147#define Blt_ColorImagePixel(c, x, y) ((c)->bits + ((c)->width * (y)) + (x))
148
149/*
150 *----------------------------------------------------------------------
151 *
152 * ResampleFilterProc --
153 *
154 * A function implementing a 1-D filter.
155 *
156 *----------------------------------------------------------------------
157 */
158typedef double (ResampleFilterProc) _ANSI_ARGS_((double value));
159
160/*
161 *----------------------------------------------------------------------
162 *
163 * ResampleFilter --
164 *
165 * Contains information about a 1-D filter (its support and
166 * the procedure implementing the filter).
167 *
168 *----------------------------------------------------------------------
169 */
170typedef struct {
171 char *name; /* Name of the filter */
172 ResampleFilterProc *proc; /* 1-D filter procedure. */
173 double support; /* Width of 1-D filter */
174} ResampleFilter;
175
176extern ResampleFilter *bltBoxFilterPtr; /* The ubiquitous box filter */
177
178
179/*
180 *----------------------------------------------------------------------
181 *
182 * Filter2D --
183 *
184 * Defines a convolution mask for a 2-D filter. Used to smooth or
185 * enhance images.
186 *
187 *----------------------------------------------------------------------
188 */
189typedef struct {
190 double support; /* Radius of filter */
191 double sum, scale; /* Sum of kernel */
192 double *kernel; /* Array of values (malloc-ed) representing
193 * the discrete 2-D filter. */
194} Filter2D;
195
196/* Prototypes of image routines */
197
198extern void Blt_ColorImageToGreyscale _ANSI_ARGS_((Blt_ColorImage image));
199
200extern void Blt_ColorImageToPhoto _ANSI_ARGS_((Blt_ColorImage image,
201 Tk_PhotoHandle photo));
202
203extern Pixmap Blt_ColorImageToPixmap _ANSI_ARGS_((Tcl_Interp *interp,
204 Tk_Window tkwin, Blt_ColorImage image, ColorTable *colorTablePtr));
205
206extern Blt_ColorImage Blt_ConvolveColorImage _ANSI_ARGS_((
207 Blt_ColorImage srcImage, Filter2D *filter));
208
209extern Blt_ColorImage Blt_CreateColorImage _ANSI_ARGS_((int width,int height));
210
211extern Blt_ColorImage Blt_DrawableToColorImage _ANSI_ARGS_((Tk_Window tkwin,
212 Drawable drawable, int x, int y, int width, int height,
213 double inputGamma));
214
215extern int Blt_GetResampleFilter _ANSI_ARGS_((Tcl_Interp *interp,
216 char *filterName, ResampleFilter **filterPtrPtr));
217
218extern void Blt_FreeColorImage _ANSI_ARGS_((Blt_ColorImage image));
219
220#if HAVE_JPEG
221extern Blt_ColorImage Blt_JPEGToColorImage _ANSI_ARGS_((Tcl_Interp *interp,
222 char *fileName));
223#endif
224
225extern Blt_ColorImage Blt_PhotoToColorImage _ANSI_ARGS_((
226 Tk_PhotoHandle photo));
227
228extern Blt_ColorImage Blt_PhotoRegionToColorImage _ANSI_ARGS_((
229 Tk_PhotoHandle photo, int x, int y, int width, int height));
230
231extern int Blt_QuantizeColorImage _ANSI_ARGS_((Blt_ColorImage src,
232 Blt_ColorImage dest, int nColors));
233
234extern Blt_ColorImage Blt_ResampleColorImage _ANSI_ARGS_((Blt_ColorImage image,
235 int destWidth, int destHeight, ResampleFilter *horzFilterPtr,
236 ResampleFilter *vertFilterPtr));
237
238extern void Blt_ResamplePhoto _ANSI_ARGS_((Tk_PhotoHandle srcPhoto,
239 int x, int y, int width, int height, Tk_PhotoHandle destPhoto,
240 ResampleFilter *horzFilterPtr, ResampleFilter *vertFilterPtr));
241
242extern Blt_ColorImage Blt_ResizeColorImage _ANSI_ARGS_((Blt_ColorImage src,
243 int x, int y, int width, int height, int destWidth, int destHeight));
244
245extern Blt_ColorImage Blt_ResizeColorSubimage _ANSI_ARGS_((Blt_ColorImage src,
246 int x, int y, int width, int height, int destWidth, int destHeight));
247
248extern Blt_ColorImage Blt_RotateColorImage _ANSI_ARGS_((Blt_ColorImage image,
249 double theta));
250
251extern void Blt_ResizePhoto _ANSI_ARGS_((Tk_PhotoHandle srcPhoto, int x, int y,
252 int width, int height, Tk_PhotoHandle destPhoto));
253
254extern int Blt_SnapPhoto _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin,
255 Drawable drawable, int x, int y, int width, int height, int destWidth,
256 int destHeight, char *photoName, double inputGamma));
257
258extern void Blt_ImageRegion _ANSI_ARGS_((Blt_ColorImage image,
259 Region2D *regionPtr));
260
261extern Region2D *Blt_ColorImageRegion _ANSI_ARGS_((Blt_ColorImage image,
262 Region2D *regionPtr));
263
264extern Region2D *Blt_SetRegion _ANSI_ARGS_((int x, int y, int width,
265 int height, Region2D *regionPtr));
266
267extern ColorTable Blt_CreateColorTable _ANSI_ARGS_((Tk_Window tkwin));
268
269extern ColorTable Blt_DirectColorTable _ANSI_ARGS_((Tcl_Interp *interp,
270 Tk_Window tkwin, Blt_ColorImage image));
271
272extern ColorTable Blt_PseudoColorTable _ANSI_ARGS_((Tcl_Interp *interp,
273 Tk_Window tkwin, Blt_ColorImage image));
274
275extern void Blt_FreeColorTable _ANSI_ARGS_((ColorTable colorTable));
276
277/* Missing routines from the Tk photo C API */
278
279extern int Tk_ImageIsDeleted _ANSI_ARGS_((Tk_Image tkImage));
280extern Tk_ImageMaster Tk_ImageGetMaster _ANSI_ARGS_((Tk_Image tkImage));
281extern Tk_ImageType *Tk_ImageGetType _ANSI_ARGS_((Tk_Image tkImage));
282extern Pixmap Tk_ImageGetPhotoPixmap _ANSI_ARGS_((Tk_Image photoImage));
283extern GC Tk_ImageGetPhotoGC _ANSI_ARGS_((Tk_Image photoImage));
284
285extern char *Blt_NameOfImage _ANSI_ARGS_((Tk_Image tkImage));
286extern Tk_Image Blt_CreateTemporaryImage _ANSI_ARGS_((Tcl_Interp *interp,
287 Tk_Window tkwin, ClientData clientData));
288extern int Blt_DestroyTemporaryImage _ANSI_ARGS_((Tcl_Interp *interp,
289 Tk_Image tkImage));
290
291extern GC Blt_GetBitmapGC _ANSI_ARGS_((Tk_Window tkwin));
292extern Pixmap Blt_PhotoImageMask _ANSI_ARGS_((Tk_Window tkwin,
293 Tk_PhotoImageBlock src));
294
295extern Pixmap Blt_RotateBitmap _ANSI_ARGS_((Tk_Window tkwin, Pixmap bitmap,
296 int width, int height, double theta, int *widthPtr, int *heightPtr));
297
298extern Pixmap Blt_ScaleBitmap _ANSI_ARGS_((Tk_Window tkwin, Pixmap srcBitmap,
299 int srcWidth, int srcHeight, int scaledWidth, int scaledHeight));
300
301extern Pixmap Blt_ScaleRotateBitmapRegion _ANSI_ARGS_((Tk_Window tkwin,
302 Pixmap srcBitmap, unsigned int srcWidth, unsigned int srcHeight,
303 int regionX, int regionY, unsigned int regionWidth,
304 unsigned int regionHeight, unsigned int virtWidth,
305 unsigned int virtHeight, double theta));
306
307#endif /*_BLT_IMAGE_H*/
Note: See TracBrowser for help on using the repository browser.