OSDN Git Service

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