Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / man / mann / photo.n
CommitLineData
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
223See 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
230Command-Line Name: \\fB\\$1\\fR
231Database Name: \\fB\\$2\\fR
232Database 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
254photo \- Full-color images
255.SH SYNOPSIS
256\fBimage create photo \fR?\fIname\fR? ?\fIoptions\fR?
257.BE
258
259.SH DESCRIPTION
260.PP
261A photo is an image whose pixels can display any color or be
262transparent. A photo image is stored internally in full color (32
263bits per pixel), and is displayed using dithering if necessary. Image
264data for a photo image can be obtained from a file or a string, or it
265can be supplied from
266C code through a procedural interface. At present, only GIF and PPM/PGM
267formats are supported, but an interface exists to allow additional
268image file formats to be added easily. A photo image is transparent
269in regions where no image data has been supplied
270.VS 8.4
271or where it has been set transparent by the \fBtransparency set\fR
272subcommand.
273.VE 8.4
274.SH "CREATING PHOTOS"
275.PP
276Like all images, photos are created using the \fBimage create\fR
277command.
278Photos support the following \fIoptions\fR:
279.TP
280\fB\-data \fIstring\fR
281Specifies the contents of the image as a string. The string can
282contain base64 encoded data or binary data. The format of the
283string must be one of those for which there is an image file format
284handler that will accept string data. If both the \fB\-data\fR
285and \fB\-file\fR options are specified, the \fB\-file\fR option takes
286precedence.
287.TP
288\fB\-format \fIformat-name\fR
289Specifies 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
294for the photo image. The file format must be one of those for which
295there is an image file format handler that can read data.
296.TP
297\fB\-gamma \fIvalue\fR
298Specifies that the colors allocated for displaying this image in a
299window should be corrected for a non-linear display with the specified
300gamma exponent value. (The intensity produced by most
301CRT displays is a power function of the input value, to a good
302approximation; gamma is the exponent and is typically around 2).
303The value specified must be greater than zero. The default
304value is one (no correction). In general, values greater than one
305will make the image lighter, and values less than one will make it
306darker.
307.TP
308\fB\-height \fInumber\fR
309Specifies the height of the image, in pixels. This option is useful
310primarily in situations where the user wishes to build up the contents
311of the image piece by piece. A value of zero (the default) allows the
312image to expand or shrink vertically to fit the data stored in it.
313.TP
314\fB\-palette \fIpalette-spec\fR
315Specifies the resolution of the color cube to be allocated for
316displaying this image, and thus the number of colors used from the
317colormaps of the windows where it is displayed. The
318\fIpalette-spec\fR string may be either a single decimal number,
319specifying the number of shades of gray to use, or three decimal
320numbers separated by slashes (/), specifying the number of shades of
321red, green and blue to use, respectively. If the first form (a single
322number) is used, the image will be displayed in monochrome (i.e.,
323grayscale).
324.TP
325\fB\-width \fInumber\fR
326Specifies the width of the image, in pixels. This option is useful
327primarily in situations where the user wishes to build up the contents
328of the image piece by piece. A value of zero (the default) allows the
329image to expand or shrink horizontally to fit the data stored in it.
330.SH "IMAGE COMMAND"
331.PP
332When a photo image is created, Tk also creates a new command
333whose name is the same as the image.
334This command may be used to invoke various operations
335on the image.
336It has the following general form:
337.CS
338\fIimageName option \fR?\fIarg arg ...\fR?
339.CE
340\fIOption\fR and the \fIarg\fRs
341determine the exact behavior of the command.
342.PP
343Those options that write data to the image generally expand the size
344of the image, if necessary, to accommodate the data written to the
345image, unless the user has specified non-zero values for the
346\fB\-width\fR and/or \fB\-height\fR configuration options, in which
347case the width and/or height, respectively, of the image will not be
348changed.
349.PP
350The following commands are possible for photo images:
351.TP
352\fIimageName \fBblank\fR
353Blank the image; that is, set the entire image to have no data, so it
354will be displayed as transparent, and the background of whatever
355window it is displayed in will show through.
356.TP
357\fIimageName \fBcget\fR \fIoption\fR
358Returns the current value of the configuration option given
359by \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?
364Query or modify the configuration options for the image.
365If no \fIoption\fR is specified, returns a list describing all of
366the available options for \fIimageName\fR (see \fBTk_ConfigureInfo\fR for
367information on the format of this list). If \fIoption\fR is specified
368with no \fIvalue\fR, then the command returns a list describing the
369one named option (this list will be identical to the corresponding
370sublist of the value returned if no \fIoption\fR is specified). If
371one or more \fIoption\-value\fR pairs are specified, then the command
372modifies the given option(s) to have the given value(s); in
373this 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?
378Copies a region from the image called \fIsourceImage\fR (which must
379be a photo image) to the image called \fIimageName\fR, possibly with
380pixel zooming and/or subsampling. If no options are specified, this
381command copies the whole of \fIsourceImage\fR into \fIimageName\fR,
382starting at coordinates (0,0) in \fIimageName\fR. The following
383options may be specified:
384.RS
385.TP
386\fB\-from \fIx1 y1 x2 y2\fR
387Specifies a rectangular sub-region of the source image to be copied.
388(\fIx1,y1\fR) and (\fIx2,y2\fR) specify diagonally opposite corners of
389the rectangle. If \fIx2\fR and \fIy2\fR are not specified, the
390default value is the bottom-right corner of the source image. The
391pixels copied will include the left and top edges of the specified
392rectangle but not the bottom or right edges. If the \fB\-from\fR
393option is not given, the default is the whole source image.
394.TP
395\fB\-to \fIx1 y1 x2 y2\fR
396Specifies a rectangular sub-region of the destination image to be
397affected. (\fIx1,y1\fR) and (\fIx2,y2\fR) specify diagonally opposite
398corners of the rectangle. If \fIx2\fR and \fIy2\fR are not specified,
399the default value is (\fIx1,y1\fR) plus the size of the source
400region (after subsampling and zooming, if specified). If \fIx2\fR and
401\fIy2\fR are specified, the source region will be replicated if
402necessary to fill the destination region in a tiled fashion.
403.TP
404\fB\-shrink\fR
405Specifies that the size of the destination image should be reduced, if
406necessary, so that the region being copied into is at the bottom-right
407corner of the image. This option will not affect the width or height
408of 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
412Specifies 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
414is not given, the default value is the same as \fIx\fR. With this
415option, each pixel in the source image will be expanded into a block
416of \fIx\fR x \fIy\fR pixels in the destination image, all the same
417color. \fIx\fR and \fIy\fR must be greater than 0.
418.TP
419\fB\-subsample \fIx y\fR
420Specifies that the source image should be reduced in size by using
421only every \fIx\fRth pixel in the X direction and \fIy\fRth pixel in
422the Y direction. Negative values will cause the image to be flipped
423about the Y or X axes, respectively. If \fIy\fR is not given, the
424default value is the same as \fIx\fR.
425.TP
426\fB\-compositingrule \fIrule\fR
427.VS 8.4
428Specifies how transparent pixels in the source image are combined with
429the destination image. When a compositing rule of \fIoverlay\fR is
430set, the old contents of the destination image are visible, as if the
431source image were printed on a piece of transparent film and placed
432over the top of the destination. When a compositing rule of \fIset\fR
433is set, the old contents of the destination image are discarded and
434the 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?
440Returns image data in the form of a string. The following options
441may be specified:
442.RS
443.TP
444\fB\-background\fI color\fR
445If the color is specified, the data will not contain any transparency
446information. In all transparent pixels the color will be replaced by
447the specified color.
448.TP
449\fB\-format\fI format-name\fR
450Specifies the name of the image file format handler to be used.
451Specifically, this subcommand searches
452for the first handler whose name matches an initial substring of
453\fIformat-name\fR and which has the capability to read this image data.
454If this option is not given, this subcommand uses the first
455handler that has the capability to read the image data.
456.TP
457\fB\-from \fIx1 y1 x2 y2\fR
458Specifies a rectangular region of \fIimageName\fR to be returned.
459If only \fIx1\fR and \fIy1\fR are specified, the region
460extends from \fI(x1,y1)\fR to the bottom-right corner of
461\fIimageName\fR. If all four coordinates are given, they specify
462diagonally opposite corners of the rectangular region, including x1,y1
463and excluding x2,y2. The default, if this option is not given, is the
464whole image.
465.TP
466\fB\-grayscale\fR
467If this options is specified, the data will not contain color
468information. All pixel data will be transformed into grayscale.
469.RE
470.TP
471\fIimageName \fBget\fR \fIx y\fR
472Returns the color of the pixel at coordinates (\fIx\fR,\fIy\fR) in the
473image as a list of three integers between 0 and 255, representing the
474red, green and blue components respectively.
475.TP
476\fIimageName \fBput\fR \fIdata\fR ?\fIoption value(s) ...\fR?
477Sets pixels in \fI imageName\fR to the data specified in \fIdata\fR.
478This command first searches the list of image file format handlers for
479a handler that can interpret the data in \fIdata\fR, and then reads
480the image encoded within into \fIimageName\fR (the destination image).
481If \fIdata\fR does not match any known format, an attempt to interpret
482it as a (top-to-bottom) list of scan-lines is made, with each
483scan-line being a (left-to-right) list of pixel colors (see
484\fBTk_GetColor\fR for a description of valid colors.) Every scan-line
485must be of the same length. Note that when \fIdata\fR is a single
486color name, you are instructing Tk to fill a rectangular region with
487that color. The following options may be specified:
488.RS
489.TP
490\fB\-format \fIformat-name\fR
491Specifies the format of the image data in \fIdata\fR.
492Specifically, only image file format handlers whose names begin with
493\fIformat-name\fR will be used while searching for an image data
494format handler to read the data.
495.TP
496\fB\-to \fIx1 y1\fR ?\fIx2 y2\fR?
497Specifies the coordinates of the top-left corner (\fIx1\fR,\fIy1\fR)
498of the region of \fIimageName\fR into which data from \fIfilename\fR
499are to be read. The default is (0,0). If \fIx2\fR,\fIy2\fR is given
500and \fIdata\fR is not large enough to cover the rectangle specified by
501this option, the image data extracted will be tiled so it covers the
502entire destination rectangle. Note that if \fIdata\fR specifies a
503single color value, then a region extending to the bottom-right corner
504represented 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?
508Reads image data from the file named \fIfilename\fR into the image.
509This command first searches the list of
510image file format handlers for a handler that can interpret the data
511in \fIfilename\fR, and then reads the image in \fIfilename\fR into
512\fIimageName\fR (the destination image). The following options may be
513specified:
514.RS
515.TP
516\fB\-format \fIformat-name\fR
517Specifies the format of the image data in \fIfilename\fR.
518Specifically, only image file format handlers whose names begin with
519\fIformat-name\fR will be used while searching for an image data
520format handler to read the data.
521.TP
522\fB\-from \fIx1 y1 x2 y2\fR
523Specifies a rectangular sub-region of the image file data to be copied
524to the destination image. If only \fIx1\fR and \fIy1\fR are
525specified, the region extends from (\fIx1,y1\fR) to the bottom-right
526corner of the image in the image file. If all four coordinates are
527specified, they specify diagonally opposite corners or the region.
528The default, if this option is not specified, is the whole of the
529image in the image file.
530.TP
531\fB\-shrink\fR
532If this option, the size of \fIimageName\fR will be reduced, if
533necessary, so that the region into which the image file data are read
534is at the bottom-right corner of the \fIimageName\fR. This option
535will not affect the width or height of the image if the user has
536specified a non-zero value for the \fB\-width\fR or \fB\-height\fR
537configuration option, respectively.
538.TP
539\fB\-to \fIx y\fR
540Specifies the coordinates of the top-left corner of the region of
541\fIimageName\fR into which data from \fIfilename\fR are to be read.
542The default is (0,0).
543.RE
544.TP
545\fIimageName \fBredither\fR
546The dithering algorithm used in displaying photo images propagates
547quantization errors from one pixel to its neighbors.
548If the image data for \fIimageName\fR is supplied in pieces, the
549dithered image may not be exactly correct. Normally the difference is
550not noticeable, but if it is a problem, this command can be used to
551recalculate the dithered image in each window where the image is
552displayed.
553.TP
554\fIimageName \fBtransparency \fIsubcommand ?arg arg ...?\fR
555.VS 8.4
556Allows examination and manipulation of the transparency information in
557the photo image. Several subcommands are available:
558.RS
559.TP
560\fIimageName \fBtransparency get \fIx y\fR
561Returns a boolean indicating if the pixel at (\fIx\fR,\fIy\fR) is
562transparent.
563.TP
564\fIimageName \fBtransparency set \fIx y boolean\fR
565Makes the pixel at (\fIx\fR,\fIy\fR) transparent if \fIboolean\fR is
566true, and makes that pixel opaque otherwise.
567.RE
568.VE 8.4
569.TP
570\fIimageName \fBwrite \fIfilename\fR ?\fIoption value(s) ...\fR?
571Writes image data from \fIimageName\fR to a file named \fIfilename\fR.
572The following options may be specified:
573.RS
574.TP
575\fB\-background\fI color\fR
576If the color is specified, the data will not contain any transparency
577information. In all transparent pixels the color will be replaced by
578the specified color.
579.TP
580\fB\-format\fI format-name\fR
581Specifies the name of the image file format handler to be used to
582write the data to the file. Specifically, this subcommand searches
583for the first handler whose name matches an initial substring of
584\fIformat-name\fR and which has the capability to write an image
585file. If this option is not given, this subcommand uses the first
586handler that has the capability to write an image file.
587.TP
588\fB\-from \fIx1 y1 x2 y2\fR
589Specifies a rectangular region of \fIimageName\fR to be written to the
590image file. If only \fIx1\fR and \fIy1\fR are specified, the region
591extends from \fI(x1,y1)\fR to the bottom-right corner of
592\fIimageName\fR. If all four coordinates are given, they specify
593diagonally opposite corners of the rectangular region. The default,
594if this option is not given, is the whole image.
595.TP
596\fB\-grayscale\fR
597If this options is specified, the data will not contain color
598information. All pixel data will be transformed into grayscale.
599.RE
600.SH "IMAGE FORMATS"
601.PP
602The photo image code is structured to allow handlers for additional
603image file formats to be added easily. The photo image code maintains
604a list of these handlers. Handlers are added to the list by
605registering them with a call to \fBTk_CreatePhotoImageFormat\fR. The
606standard Tk distribution comes with handlers for PPM/PGM and GIF formats,
607which are automatically registered on initialization.
608.PP
609When reading an image file or processing
610string data specified with the \fB\-data\fR configuration option, the
611photo image code invokes each handler in turn until one is
612found that claims to be able to read the data in the file or string.
613Usually this will find the correct handler, but if it doesn't, the
614user may give a format name with the \fB\-format\fR option to specify
615which handler to use. In fact the photo image code will try those
616handlers whose names begin with the string specified for the
617\fB\-format\fR option (the comparison is case-insensitive). For
618example, if the user specifies \fB\-format gif\fR, then a handler
619named GIF87 or GIF89 may be invoked, but a handler
620named JPEG may not (assuming that such handlers had been
621registered).
622.PP
623When writing image data to a file, the processing of the
624\fB\-format\fR option is slightly different: the string value given
625for the \fB\-format\fR option must begin with the complete name of the
626requested handler, and may contain additional information following
627that, which the handler can use, for example, to specify which variant
628to use of the formats supported by the handler.
629.VS 8.4
630Note that not all image handlers may support writing transparency data
631to a file, even where the target image format does.
632.VE 8.4
633.SH "COLOR ALLOCATION"
634.PP
635When a photo image is displayed in a window, the photo image code
636allocates colors to use to display the image and dithers the image, if
637necessary, to display a reasonable approximation to the image using
638the colors that are available. The colors are allocated as a color
639cube, that is, the number of colors allocated is the product of the
640number of shades of red, green and blue.
641.PP
642Normally, the number of
643colors allocated is chosen based on the depth of the window. For
644example, in an 8-bit PseudoColor window, the photo image code will
645attempt to allocate seven shades of red, seven shades of green and
646four 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
648a 24-bit DirectColor or TrueColor window, it will allocate 256 shades
649each of red, green and blue. Fortunately, because of the way that
650pixel values can be combined in DirectColor and TrueColor windows,
651this only requires 256 colors to be allocated. If not all of the
652colors can be allocated, the photo image code reduces the number of
653shades of each primary color and tries again.
654.PP
655The user can exercise some control over the number of colors that a
656photo image uses with the \fB\-palette\fR configuration option. If
657this option is used, it specifies the maximum number of shades of
658each primary color to try to allocate. It can also be used to force
659the image to be displayed in shades of gray, even on a color display,
660by giving a single number rather than three numbers separated by
661slashes.
662.SH CREDITS
663.PP
664The photo image type was designed and implemented by Paul Mackerras,
665based on his earlier photo widget and some suggestions from
666John Ousterhout.
667.SH EXAMPLE
668Load an image from a file and tile it to the size of a window, which
669is 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
677set width [winfo width .someWidget]
678set height [winfo height .someWidget]
679tiled \fBcopy\fR untiled \-to 0 0 $width $height \-shrink
680.CE
681
682.SH "SEE ALSO"
683image(n)
684
685.SH KEYWORDS
686photo, image, color