Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | '\" |
2 | '\" Copyright (c) 1994 The Australian National University | |
3 | '\" Copyright (c) 1994-1997 Sun Microsystems, Inc. | |
4 | '\" | |
5 | '\" See the file "license.terms" for information on usage and redistribution | |
6 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. | |
7 | '\" | |
8 | '\" Author: Paul Mackerras (paulus@cs.anu.edu.au), | |
9 | '\" Department of Computer Science, | |
10 | '\" Australian National University. | |
11 | '\" | |
12 | '\" RCS: @(#) $Id: photo.n,v 1.14.2.4 2004/10/28 12:25:22 dkf Exp $ | |
13 | '\" | |
14 | '\" The definitions below are for supplemental macros used in Tcl/Tk | |
15 | '\" manual entries. | |
16 | '\" | |
17 | '\" .AP type name in/out ?indent? | |
18 | '\" Start paragraph describing an argument to a library procedure. | |
19 | '\" type is type of argument (int, etc.), in/out is either "in", "out", | |
20 | '\" or "in/out" to describe whether procedure reads or modifies arg, | |
21 | '\" and indent is equivalent to second arg of .IP (shouldn't ever be | |
22 | '\" needed; use .AS below instead) | |
23 | '\" | |
24 | '\" .AS ?type? ?name? | |
25 | '\" Give maximum sizes of arguments for setting tab stops. Type and | |
26 | '\" name are examples of largest possible arguments that will be passed | |
27 | '\" to .AP later. If args are omitted, default tab stops are used. | |
28 | '\" | |
29 | '\" .BS | |
30 | '\" Start box enclosure. From here until next .BE, everything will be | |
31 | '\" enclosed in one large box. | |
32 | '\" | |
33 | '\" .BE | |
34 | '\" End of box enclosure. | |
35 | '\" | |
36 | '\" .CS | |
37 | '\" Begin code excerpt. | |
38 | '\" | |
39 | '\" .CE | |
40 | '\" End code excerpt. | |
41 | '\" | |
42 | '\" .VS ?version? ?br? | |
43 | '\" Begin vertical sidebar, for use in marking newly-changed parts | |
44 | '\" of man pages. The first argument is ignored and used for recording | |
45 | '\" the version when the .VS was added, so that the sidebars can be | |
46 | '\" found and removed when they reach a certain age. If another argument | |
47 | '\" is present, then a line break is forced before starting the sidebar. | |
48 | '\" | |
49 | '\" .VE | |
50 | '\" End of vertical sidebar. | |
51 | '\" | |
52 | '\" .DS | |
53 | '\" Begin an indented unfilled display. | |
54 | '\" | |
55 | '\" .DE | |
56 | '\" End of indented unfilled display. | |
57 | '\" | |
58 | '\" .SO | |
59 | '\" Start of list of standard options for a Tk widget. The | |
60 | '\" options follow on successive lines, in four columns separated | |
61 | '\" by tabs. | |
62 | '\" | |
63 | '\" .SE | |
64 | '\" End of list of standard options for a Tk widget. | |
65 | '\" | |
66 | '\" .OP cmdName dbName dbClass | |
67 | '\" Start of description of a specific option. cmdName gives the | |
68 | '\" option's name as specified in the class command, dbName gives | |
69 | '\" the option's name in the option database, and dbClass gives | |
70 | '\" the option's class in the option database. | |
71 | '\" | |
72 | '\" .UL arg1 arg2 | |
73 | '\" Print arg1 underlined, then print arg2 normally. | |
74 | '\" | |
75 | '\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $ | |
76 | '\" | |
77 | '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. | |
78 | .if t .wh -1.3i ^B | |
79 | .nr ^l \n(.l | |
80 | .ad b | |
81 | '\" # Start an argument description | |
82 | .de AP | |
83 | .ie !"\\$4"" .TP \\$4 | |
84 | .el \{\ | |
85 | . ie !"\\$2"" .TP \\n()Cu | |
86 | . el .TP 15 | |
87 | .\} | |
88 | .ta \\n()Au \\n()Bu | |
89 | .ie !"\\$3"" \{\ | |
90 | \&\\$1 \\fI\\$2\\fP (\\$3) | |
91 | .\".b | |
92 | .\} | |
93 | .el \{\ | |
94 | .br | |
95 | .ie !"\\$2"" \{\ | |
96 | \&\\$1 \\fI\\$2\\fP | |
97 | .\} | |
98 | .el \{\ | |
99 | \&\\fI\\$1\\fP | |
100 | .\} | |
101 | .\} | |
102 | .. | |
103 | '\" # define tabbing values for .AP | |
104 | .de AS | |
105 | .nr )A 10n | |
106 | .if !"\\$1"" .nr )A \\w'\\$1'u+3n | |
107 | .nr )B \\n()Au+15n | |
108 | .\" | |
109 | .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n | |
110 | .nr )C \\n()Bu+\\w'(in/out)'u+2n | |
111 | .. | |
112 | .AS Tcl_Interp Tcl_CreateInterp in/out | |
113 | '\" # BS - start boxed text | |
114 | '\" # ^y = starting y location | |
115 | '\" # ^b = 1 | |
116 | .de BS | |
117 | .br | |
118 | .mk ^y | |
119 | .nr ^b 1u | |
120 | .if n .nf | |
121 | .if n .ti 0 | |
122 | .if n \l'\\n(.lu\(ul' | |
123 | .if n .fi | |
124 | .. | |
125 | '\" # BE - end boxed text (draw box now) | |
126 | .de BE | |
127 | .nf | |
128 | .ti 0 | |
129 | .mk ^t | |
130 | .ie n \l'\\n(^lu\(ul' | |
131 | .el \{\ | |
132 | .\" Draw four-sided box normally, but don't draw top of | |
133 | .\" box if the box started on an earlier page. | |
134 | .ie !\\n(^b-1 \{\ | |
135 | \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' | |
136 | .\} | |
137 | .el \}\ | |
138 | \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' | |
139 | .\} | |
140 | .\} | |
141 | .fi | |
142 | .br | |
143 | .nr ^b 0 | |
144 | .. | |
145 | '\" # VS - start vertical sidebar | |
146 | '\" # ^Y = starting y location | |
147 | '\" # ^v = 1 (for troff; for nroff this doesn't matter) | |
148 | .de VS | |
149 | .if !"\\$2"" .br | |
150 | .mk ^Y | |
151 | .ie n 'mc \s12\(br\s0 | |
152 | .el .nr ^v 1u | |
153 | .. | |
154 | '\" # VE - end of vertical sidebar | |
155 | .de VE | |
156 | .ie n 'mc | |
157 | .el \{\ | |
158 | .ev 2 | |
159 | .nf | |
160 | .ti 0 | |
161 | .mk ^t | |
162 | \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' | |
163 | .sp -1 | |
164 | .fi | |
165 | .ev | |
166 | .\} | |
167 | .nr ^v 0 | |
168 | .. | |
169 | '\" # Special macro to handle page bottom: finish off current | |
170 | '\" # box/sidebar if in box/sidebar mode, then invoked standard | |
171 | '\" # page bottom macro. | |
172 | .de ^B | |
173 | .ev 2 | |
174 | 'ti 0 | |
175 | 'nf | |
176 | .mk ^t | |
177 | .if \\n(^b \{\ | |
178 | .\" Draw three-sided box if this is the box's first page, | |
179 | .\" draw two sides but no top otherwise. | |
180 | .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c | |
181 | .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c | |
182 | .\} | |
183 | .if \\n(^v \{\ | |
184 | .nr ^x \\n(^tu+1v-\\n(^Yu | |
185 | \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c | |
186 | .\} | |
187 | .bp | |
188 | 'fi | |
189 | .ev | |
190 | .if \\n(^b \{\ | |
191 | .mk ^y | |
192 | .nr ^b 2 | |
193 | .\} | |
194 | .if \\n(^v \{\ | |
195 | .mk ^Y | |
196 | .\} | |
197 | .. | |
198 | '\" # DS - begin display | |
199 | .de DS | |
200 | .RS | |
201 | .nf | |
202 | .sp | |
203 | .. | |
204 | '\" # DE - end display | |
205 | .de DE | |
206 | .fi | |
207 | .RE | |
208 | .sp | |
209 | .. | |
210 | '\" # SO - start of list of standard options | |
211 | .de SO | |
212 | .SH "STANDARD OPTIONS" | |
213 | .LP | |
214 | .nf | |
215 | .ta 5.5c 11c | |
216 | .ft B | |
217 | .. | |
218 | '\" # SE - end of list of standard options | |
219 | .de SE | |
220 | .fi | |
221 | .ft R | |
222 | .LP | |
223 | See the \\fBoptions\\fR manual entry for details on the standard options. | |
224 | .. | |
225 | '\" # OP - start of full description for a single option | |
226 | .de OP | |
227 | .LP | |
228 | .nf | |
229 | .ta 4c | |
230 | Command-Line Name: \\fB\\$1\\fR | |
231 | Database Name: \\fB\\$2\\fR | |
232 | Database Class: \\fB\\$3\\fR | |
233 | .fi | |
234 | .IP | |
235 | .. | |
236 | '\" # CS - begin code excerpt | |
237 | .de CS | |
238 | .RS | |
239 | .nf | |
240 | .ta .25i .5i .75i 1i | |
241 | .. | |
242 | '\" # CE - end code excerpt | |
243 | .de CE | |
244 | .fi | |
245 | .RE | |
246 | .. | |
247 | .de UL | |
248 | \\$1\l'|0\(ul'\\$2 | |
249 | .. | |
250 | .TH photo n 4.0 Tk "Tk Built-In Commands" | |
251 | .BS | |
252 | '\" Note: do not modify the .SH NAME line immediately below! | |
253 | .SH NAME | |
254 | photo \- Full-color images | |
255 | .SH SYNOPSIS | |
256 | \fBimage create photo \fR?\fIname\fR? ?\fIoptions\fR? | |
257 | .BE | |
258 | ||
259 | .SH DESCRIPTION | |
260 | .PP | |
261 | A photo is an image whose pixels can display any color or be | |
262 | transparent. A photo image is stored internally in full color (32 | |
263 | bits per pixel), and is displayed using dithering if necessary. Image | |
264 | data for a photo image can be obtained from a file or a string, or it | |
265 | can be supplied from | |
266 | C code through a procedural interface. At present, only GIF and PPM/PGM | |
267 | formats are supported, but an interface exists to allow additional | |
268 | image file formats to be added easily. A photo image is transparent | |
269 | in regions where no image data has been supplied | |
270 | .VS 8.4 | |
271 | or where it has been set transparent by the \fBtransparency set\fR | |
272 | subcommand. | |
273 | .VE 8.4 | |
274 | .SH "CREATING PHOTOS" | |
275 | .PP | |
276 | Like all images, photos are created using the \fBimage create\fR | |
277 | command. | |
278 | Photos support the following \fIoptions\fR: | |
279 | .TP | |
280 | \fB\-data \fIstring\fR | |
281 | Specifies the contents of the image as a string. The string can | |
282 | contain base64 encoded data or binary data. The format of the | |
283 | string must be one of those for which there is an image file format | |
284 | handler that will accept string data. If both the \fB\-data\fR | |
285 | and \fB\-file\fR options are specified, the \fB\-file\fR option takes | |
286 | precedence. | |
287 | .TP | |
288 | \fB\-format \fIformat-name\fR | |
289 | Specifies the name of the file format for the data specified with the | |
290 | \fB\-data\fR or \fB\-file\fR option. | |
291 | .TP | |
292 | \fB\-file \fIname\fR | |
293 | \fIname\fR gives the name of a file that is to be read to supply data | |
294 | for the photo image. The file format must be one of those for which | |
295 | there is an image file format handler that can read data. | |
296 | .TP | |
297 | \fB\-gamma \fIvalue\fR | |
298 | Specifies that the colors allocated for displaying this image in a | |
299 | window should be corrected for a non-linear display with the specified | |
300 | gamma exponent value. (The intensity produced by most | |
301 | CRT displays is a power function of the input value, to a good | |
302 | approximation; gamma is the exponent and is typically around 2). | |
303 | The value specified must be greater than zero. The default | |
304 | value is one (no correction). In general, values greater than one | |
305 | will make the image lighter, and values less than one will make it | |
306 | darker. | |
307 | .TP | |
308 | \fB\-height \fInumber\fR | |
309 | Specifies the height of the image, in pixels. This option is useful | |
310 | primarily in situations where the user wishes to build up the contents | |
311 | of the image piece by piece. A value of zero (the default) allows the | |
312 | image to expand or shrink vertically to fit the data stored in it. | |
313 | .TP | |
314 | \fB\-palette \fIpalette-spec\fR | |
315 | Specifies the resolution of the color cube to be allocated for | |
316 | displaying this image, and thus the number of colors used from the | |
317 | colormaps of the windows where it is displayed. The | |
318 | \fIpalette-spec\fR string may be either a single decimal number, | |
319 | specifying the number of shades of gray to use, or three decimal | |
320 | numbers separated by slashes (/), specifying the number of shades of | |
321 | red, green and blue to use, respectively. If the first form (a single | |
322 | number) is used, the image will be displayed in monochrome (i.e., | |
323 | grayscale). | |
324 | .TP | |
325 | \fB\-width \fInumber\fR | |
326 | Specifies the width of the image, in pixels. This option is useful | |
327 | primarily in situations where the user wishes to build up the contents | |
328 | of the image piece by piece. A value of zero (the default) allows the | |
329 | image to expand or shrink horizontally to fit the data stored in it. | |
330 | .SH "IMAGE COMMAND" | |
331 | .PP | |
332 | When a photo image is created, Tk also creates a new command | |
333 | whose name is the same as the image. | |
334 | This command may be used to invoke various operations | |
335 | on the image. | |
336 | It has the following general form: | |
337 | .CS | |
338 | \fIimageName option \fR?\fIarg arg ...\fR? | |
339 | .CE | |
340 | \fIOption\fR and the \fIarg\fRs | |
341 | determine the exact behavior of the command. | |
342 | .PP | |
343 | Those options that write data to the image generally expand the size | |
344 | of the image, if necessary, to accommodate the data written to the | |
345 | image, unless the user has specified non-zero values for the | |
346 | \fB\-width\fR and/or \fB\-height\fR configuration options, in which | |
347 | case the width and/or height, respectively, of the image will not be | |
348 | changed. | |
349 | .PP | |
350 | The following commands are possible for photo images: | |
351 | .TP | |
352 | \fIimageName \fBblank\fR | |
353 | Blank the image; that is, set the entire image to have no data, so it | |
354 | will be displayed as transparent, and the background of whatever | |
355 | window it is displayed in will show through. | |
356 | .TP | |
357 | \fIimageName \fBcget\fR \fIoption\fR | |
358 | Returns the current value of the configuration option given | |
359 | by \fIoption\fR. | |
360 | \fIOption\fR may have any of the values accepted by the | |
361 | \fBimage create photo\fR command. | |
362 | .TP | |
363 | \fIimageName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? | |
364 | Query or modify the configuration options for the image. | |
365 | If no \fIoption\fR is specified, returns a list describing all of | |
366 | the available options for \fIimageName\fR (see \fBTk_ConfigureInfo\fR for | |
367 | information on the format of this list). If \fIoption\fR is specified | |
368 | with no \fIvalue\fR, then the command returns a list describing the | |
369 | one named option (this list will be identical to the corresponding | |
370 | sublist of the value returned if no \fIoption\fR is specified). If | |
371 | one or more \fIoption\-value\fR pairs are specified, then the command | |
372 | modifies the given option(s) to have the given value(s); in | |
373 | this case the command returns an empty string. | |
374 | \fIOption\fR may have any of the values accepted by the | |
375 | \fBimage create photo\fR command. | |
376 | .TP | |
377 | \fIimageName \fBcopy\fR \fIsourceImage\fR ?\fIoption value(s) ...\fR? | |
378 | Copies a region from the image called \fIsourceImage\fR (which must | |
379 | be a photo image) to the image called \fIimageName\fR, possibly with | |
380 | pixel zooming and/or subsampling. If no options are specified, this | |
381 | command copies the whole of \fIsourceImage\fR into \fIimageName\fR, | |
382 | starting at coordinates (0,0) in \fIimageName\fR. The following | |
383 | options may be specified: | |
384 | .RS | |
385 | .TP | |
386 | \fB\-from \fIx1 y1 x2 y2\fR | |
387 | Specifies a rectangular sub-region of the source image to be copied. | |
388 | (\fIx1,y1\fR) and (\fIx2,y2\fR) specify diagonally opposite corners of | |
389 | the rectangle. If \fIx2\fR and \fIy2\fR are not specified, the | |
390 | default value is the bottom-right corner of the source image. The | |
391 | pixels copied will include the left and top edges of the specified | |
392 | rectangle but not the bottom or right edges. If the \fB\-from\fR | |
393 | option is not given, the default is the whole source image. | |
394 | .TP | |
395 | \fB\-to \fIx1 y1 x2 y2\fR | |
396 | Specifies a rectangular sub-region of the destination image to be | |
397 | affected. (\fIx1,y1\fR) and (\fIx2,y2\fR) specify diagonally opposite | |
398 | corners of the rectangle. If \fIx2\fR and \fIy2\fR are not specified, | |
399 | the default value is (\fIx1,y1\fR) plus the size of the source | |
400 | region (after subsampling and zooming, if specified). If \fIx2\fR and | |
401 | \fIy2\fR are specified, the source region will be replicated if | |
402 | necessary to fill the destination region in a tiled fashion. | |
403 | .TP | |
404 | \fB\-shrink\fR | |
405 | Specifies that the size of the destination image should be reduced, if | |
406 | necessary, so that the region being copied into is at the bottom-right | |
407 | corner of the image. This option will not affect the width or height | |
408 | of the image if the user has specified a non-zero value for the | |
409 | \fB\-width\fR or \fB\-height\fR configuration option, respectively. | |
410 | .TP | |
411 | \fB\-zoom \fIx y\fR | |
412 | Specifies that the source region should be magnified by a factor of | |
413 | \fIx\fR in the X direction and \fIy\fR in the Y direction. If \fIy\fR | |
414 | is not given, the default value is the same as \fIx\fR. With this | |
415 | option, each pixel in the source image will be expanded into a block | |
416 | of \fIx\fR x \fIy\fR pixels in the destination image, all the same | |
417 | color. \fIx\fR and \fIy\fR must be greater than 0. | |
418 | .TP | |
419 | \fB\-subsample \fIx y\fR | |
420 | Specifies that the source image should be reduced in size by using | |
421 | only every \fIx\fRth pixel in the X direction and \fIy\fRth pixel in | |
422 | the Y direction. Negative values will cause the image to be flipped | |
423 | about the Y or X axes, respectively. If \fIy\fR is not given, the | |
424 | default value is the same as \fIx\fR. | |
425 | .TP | |
426 | \fB\-compositingrule \fIrule\fR | |
427 | .VS 8.4 | |
428 | Specifies how transparent pixels in the source image are combined with | |
429 | the destination image. When a compositing rule of \fIoverlay\fR is | |
430 | set, the old contents of the destination image are visible, as if the | |
431 | source image were printed on a piece of transparent film and placed | |
432 | over the top of the destination. When a compositing rule of \fIset\fR | |
433 | is set, the old contents of the destination image are discarded and | |
434 | the source image is used as-is. The default compositing rule is | |
435 | \fIoverlay\fR. | |
436 | .VE 8.4 | |
437 | .RE | |
438 | .TP | |
439 | \fIimageName \fBdata ?\fIoption value(s) ...\fR? | |
440 | Returns image data in the form of a string. The following options | |
441 | may be specified: | |
442 | .RS | |
443 | .TP | |
444 | \fB\-background\fI color\fR | |
445 | If the color is specified, the data will not contain any transparency | |
446 | information. In all transparent pixels the color will be replaced by | |
447 | the specified color. | |
448 | .TP | |
449 | \fB\-format\fI format-name\fR | |
450 | Specifies the name of the image file format handler to be used. | |
451 | Specifically, this subcommand searches | |
452 | for the first handler whose name matches an initial substring of | |
453 | \fIformat-name\fR and which has the capability to read this image data. | |
454 | If this option is not given, this subcommand uses the first | |
455 | handler that has the capability to read the image data. | |
456 | .TP | |
457 | \fB\-from \fIx1 y1 x2 y2\fR | |
458 | Specifies a rectangular region of \fIimageName\fR to be returned. | |
459 | If only \fIx1\fR and \fIy1\fR are specified, the region | |
460 | extends from \fI(x1,y1)\fR to the bottom-right corner of | |
461 | \fIimageName\fR. If all four coordinates are given, they specify | |
462 | diagonally opposite corners of the rectangular region, including x1,y1 | |
463 | and excluding x2,y2. The default, if this option is not given, is the | |
464 | whole image. | |
465 | .TP | |
466 | \fB\-grayscale\fR | |
467 | If this options is specified, the data will not contain color | |
468 | information. All pixel data will be transformed into grayscale. | |
469 | .RE | |
470 | .TP | |
471 | \fIimageName \fBget\fR \fIx y\fR | |
472 | Returns the color of the pixel at coordinates (\fIx\fR,\fIy\fR) in the | |
473 | image as a list of three integers between 0 and 255, representing the | |
474 | red, green and blue components respectively. | |
475 | .TP | |
476 | \fIimageName \fBput\fR \fIdata\fR ?\fIoption value(s) ...\fR? | |
477 | Sets pixels in \fI imageName\fR to the data specified in \fIdata\fR. | |
478 | This command first searches the list of image file format handlers for | |
479 | a handler that can interpret the data in \fIdata\fR, and then reads | |
480 | the image encoded within into \fIimageName\fR (the destination image). | |
481 | If \fIdata\fR does not match any known format, an attempt to interpret | |
482 | it as a (top-to-bottom) list of scan-lines is made, with each | |
483 | scan-line being a (left-to-right) list of pixel colors (see | |
484 | \fBTk_GetColor\fR for a description of valid colors.) Every scan-line | |
485 | must be of the same length. Note that when \fIdata\fR is a single | |
486 | color name, you are instructing Tk to fill a rectangular region with | |
487 | that color. The following options may be specified: | |
488 | .RS | |
489 | .TP | |
490 | \fB\-format \fIformat-name\fR | |
491 | Specifies the format of the image data in \fIdata\fR. | |
492 | Specifically, only image file format handlers whose names begin with | |
493 | \fIformat-name\fR will be used while searching for an image data | |
494 | format handler to read the data. | |
495 | .TP | |
496 | \fB\-to \fIx1 y1\fR ?\fIx2 y2\fR? | |
497 | Specifies the coordinates of the top-left corner (\fIx1\fR,\fIy1\fR) | |
498 | of the region of \fIimageName\fR into which data from \fIfilename\fR | |
499 | are to be read. The default is (0,0). If \fIx2\fR,\fIy2\fR is given | |
500 | and \fIdata\fR is not large enough to cover the rectangle specified by | |
501 | this option, the image data extracted will be tiled so it covers the | |
502 | entire destination rectangle. Note that if \fIdata\fR specifies a | |
503 | single color value, then a region extending to the bottom-right corner | |
504 | represented by (\fIx2\fR,\fIy2\fR) will be filled with that color. | |
505 | .RE | |
506 | .TP | |
507 | \fIimageName \fBread\fR \fIfilename\fR ?\fIoption value(s) ...\fR? | |
508 | Reads image data from the file named \fIfilename\fR into the image. | |
509 | This command first searches the list of | |
510 | image file format handlers for a handler that can interpret the data | |
511 | in \fIfilename\fR, and then reads the image in \fIfilename\fR into | |
512 | \fIimageName\fR (the destination image). The following options may be | |
513 | specified: | |
514 | .RS | |
515 | .TP | |
516 | \fB\-format \fIformat-name\fR | |
517 | Specifies the format of the image data in \fIfilename\fR. | |
518 | Specifically, only image file format handlers whose names begin with | |
519 | \fIformat-name\fR will be used while searching for an image data | |
520 | format handler to read the data. | |
521 | .TP | |
522 | \fB\-from \fIx1 y1 x2 y2\fR | |
523 | Specifies a rectangular sub-region of the image file data to be copied | |
524 | to the destination image. If only \fIx1\fR and \fIy1\fR are | |
525 | specified, the region extends from (\fIx1,y1\fR) to the bottom-right | |
526 | corner of the image in the image file. If all four coordinates are | |
527 | specified, they specify diagonally opposite corners or the region. | |
528 | The default, if this option is not specified, is the whole of the | |
529 | image in the image file. | |
530 | .TP | |
531 | \fB\-shrink\fR | |
532 | If this option, the size of \fIimageName\fR will be reduced, if | |
533 | necessary, so that the region into which the image file data are read | |
534 | is at the bottom-right corner of the \fIimageName\fR. This option | |
535 | will not affect the width or height of the image if the user has | |
536 | specified a non-zero value for the \fB\-width\fR or \fB\-height\fR | |
537 | configuration option, respectively. | |
538 | .TP | |
539 | \fB\-to \fIx y\fR | |
540 | Specifies the coordinates of the top-left corner of the region of | |
541 | \fIimageName\fR into which data from \fIfilename\fR are to be read. | |
542 | The default is (0,0). | |
543 | .RE | |
544 | .TP | |
545 | \fIimageName \fBredither\fR | |
546 | The dithering algorithm used in displaying photo images propagates | |
547 | quantization errors from one pixel to its neighbors. | |
548 | If the image data for \fIimageName\fR is supplied in pieces, the | |
549 | dithered image may not be exactly correct. Normally the difference is | |
550 | not noticeable, but if it is a problem, this command can be used to | |
551 | recalculate the dithered image in each window where the image is | |
552 | displayed. | |
553 | .TP | |
554 | \fIimageName \fBtransparency \fIsubcommand ?arg arg ...?\fR | |
555 | .VS 8.4 | |
556 | Allows examination and manipulation of the transparency information in | |
557 | the photo image. Several subcommands are available: | |
558 | .RS | |
559 | .TP | |
560 | \fIimageName \fBtransparency get \fIx y\fR | |
561 | Returns a boolean indicating if the pixel at (\fIx\fR,\fIy\fR) is | |
562 | transparent. | |
563 | .TP | |
564 | \fIimageName \fBtransparency set \fIx y boolean\fR | |
565 | Makes the pixel at (\fIx\fR,\fIy\fR) transparent if \fIboolean\fR is | |
566 | true, and makes that pixel opaque otherwise. | |
567 | .RE | |
568 | .VE 8.4 | |
569 | .TP | |
570 | \fIimageName \fBwrite \fIfilename\fR ?\fIoption value(s) ...\fR? | |
571 | Writes image data from \fIimageName\fR to a file named \fIfilename\fR. | |
572 | The following options may be specified: | |
573 | .RS | |
574 | .TP | |
575 | \fB\-background\fI color\fR | |
576 | If the color is specified, the data will not contain any transparency | |
577 | information. In all transparent pixels the color will be replaced by | |
578 | the specified color. | |
579 | .TP | |
580 | \fB\-format\fI format-name\fR | |
581 | Specifies the name of the image file format handler to be used to | |
582 | write the data to the file. Specifically, this subcommand searches | |
583 | for the first handler whose name matches an initial substring of | |
584 | \fIformat-name\fR and which has the capability to write an image | |
585 | file. If this option is not given, this subcommand uses the first | |
586 | handler that has the capability to write an image file. | |
587 | .TP | |
588 | \fB\-from \fIx1 y1 x2 y2\fR | |
589 | Specifies a rectangular region of \fIimageName\fR to be written to the | |
590 | image file. If only \fIx1\fR and \fIy1\fR are specified, the region | |
591 | extends from \fI(x1,y1)\fR to the bottom-right corner of | |
592 | \fIimageName\fR. If all four coordinates are given, they specify | |
593 | diagonally opposite corners of the rectangular region. The default, | |
594 | if this option is not given, is the whole image. | |
595 | .TP | |
596 | \fB\-grayscale\fR | |
597 | If this options is specified, the data will not contain color | |
598 | information. All pixel data will be transformed into grayscale. | |
599 | .RE | |
600 | .SH "IMAGE FORMATS" | |
601 | .PP | |
602 | The photo image code is structured to allow handlers for additional | |
603 | image file formats to be added easily. The photo image code maintains | |
604 | a list of these handlers. Handlers are added to the list by | |
605 | registering them with a call to \fBTk_CreatePhotoImageFormat\fR. The | |
606 | standard Tk distribution comes with handlers for PPM/PGM and GIF formats, | |
607 | which are automatically registered on initialization. | |
608 | .PP | |
609 | When reading an image file or processing | |
610 | string data specified with the \fB\-data\fR configuration option, the | |
611 | photo image code invokes each handler in turn until one is | |
612 | found that claims to be able to read the data in the file or string. | |
613 | Usually this will find the correct handler, but if it doesn't, the | |
614 | user may give a format name with the \fB\-format\fR option to specify | |
615 | which handler to use. In fact the photo image code will try those | |
616 | handlers whose names begin with the string specified for the | |
617 | \fB\-format\fR option (the comparison is case-insensitive). For | |
618 | example, if the user specifies \fB\-format gif\fR, then a handler | |
619 | named GIF87 or GIF89 may be invoked, but a handler | |
620 | named JPEG may not (assuming that such handlers had been | |
621 | registered). | |
622 | .PP | |
623 | When writing image data to a file, the processing of the | |
624 | \fB\-format\fR option is slightly different: the string value given | |
625 | for the \fB\-format\fR option must begin with the complete name of the | |
626 | requested handler, and may contain additional information following | |
627 | that, which the handler can use, for example, to specify which variant | |
628 | to use of the formats supported by the handler. | |
629 | .VS 8.4 | |
630 | Note that not all image handlers may support writing transparency data | |
631 | to a file, even where the target image format does. | |
632 | .VE 8.4 | |
633 | .SH "COLOR ALLOCATION" | |
634 | .PP | |
635 | When a photo image is displayed in a window, the photo image code | |
636 | allocates colors to use to display the image and dithers the image, if | |
637 | necessary, to display a reasonable approximation to the image using | |
638 | the colors that are available. The colors are allocated as a color | |
639 | cube, that is, the number of colors allocated is the product of the | |
640 | number of shades of red, green and blue. | |
641 | .PP | |
642 | Normally, the number of | |
643 | colors allocated is chosen based on the depth of the window. For | |
644 | example, in an 8-bit PseudoColor window, the photo image code will | |
645 | attempt to allocate seven shades of red, seven shades of green and | |
646 | four shades of blue, for a total of 198 colors. In a 1-bit StaticGray | |
647 | (monochrome) window, it will allocate two colors, black and white. In | |
648 | a 24-bit DirectColor or TrueColor window, it will allocate 256 shades | |
649 | each of red, green and blue. Fortunately, because of the way that | |
650 | pixel values can be combined in DirectColor and TrueColor windows, | |
651 | this only requires 256 colors to be allocated. If not all of the | |
652 | colors can be allocated, the photo image code reduces the number of | |
653 | shades of each primary color and tries again. | |
654 | .PP | |
655 | The user can exercise some control over the number of colors that a | |
656 | photo image uses with the \fB\-palette\fR configuration option. If | |
657 | this option is used, it specifies the maximum number of shades of | |
658 | each primary color to try to allocate. It can also be used to force | |
659 | the image to be displayed in shades of gray, even on a color display, | |
660 | by giving a single number rather than three numbers separated by | |
661 | slashes. | |
662 | .SH CREDITS | |
663 | .PP | |
664 | The photo image type was designed and implemented by Paul Mackerras, | |
665 | based on his earlier photo widget and some suggestions from | |
666 | John Ousterhout. | |
667 | .SH EXAMPLE | |
668 | Load an image from a file and tile it to the size of a window, which | |
669 | is useful for producing a tiled background: | |
670 | .CS | |
671 | # These lines should be called once | |
672 | \fBimage create photo\fR untiled -file "theFile.ppm" | |
673 | \fBimage create photo\fR tiled | |
674 | ||
675 | # These lines should be called whenever .someWidget changes | |
676 | # size; a <Configure> binding is useful here | |
677 | set width [winfo width .someWidget] | |
678 | set height [winfo height .someWidget] | |
679 | tiled \fBcopy\fR untiled \-to 0 0 $width $height \-shrink | |
680 | .CE | |
681 | ||
682 | .SH "SEE ALSO" | |
683 | image(n) | |
684 | ||
685 | .SH KEYWORDS | |
686 | photo, image, color |