OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [tk/] [doc/] [photo.n] - Blame information for rev 578

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
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.1.1.1 2002-01-16 10:25:49 markom Exp $
13
'\"
14
.so man.macros
15
.TH photo n 4.0 Tk "Tk Built-In Commands"
16
.BS
17
'\" Note:  do not modify the .SH NAME line immediately below!
18
.SH NAME
19
photo \- Full-color images
20
.SH SYNOPSIS
21
\fBimage create photo \fR?\fIname\fR? ?\fIoptions\fR?
22
.BE
23
 
24
.SH DESCRIPTION
25
.PP
26
A photo is an image whose pixels can display any color or be
27
transparent.  A photo image is stored internally in full color (24
28
bits per pixel), and is displayed using dithering if necessary.  Image
29
data for a photo image can be obtained from a file or a string, or it
30
can be supplied from
31
C code through a procedural interface.  At present, only GIF and PPM/PGM
32
formats are supported, but an interface exists to allow additional
33
image file formats to be added easily.  A photo image is transparent
34
in regions where no image data has been supplied.
35
 
36
.SH "CREATING PHOTOS"
37
.PP
38
Like all images, photos are created using the \fBimage create\fR
39
command.
40
Photos support the following \fIoptions\fR:
41
.TP
42
\fB\-data \fIstring\fR
43
Specifies the contents of the image as a string.  The format of the
44
string must be one of those for which there is an image file format
45
handler that will accept string data.  If both the \fB\-data\fR
46
and \fB\-file\fR options are specified, the \fB\-file\fR option takes
47
precedence.
48
.TP
49
\fB\-format \fIformat-name\fR
50
Specifies the name of the file format for the data specified with the
51
\fB\-data\fR or \fB\-file\fR option.
52
.TP
53
\fB\-file \fIname\fR
54
\fIname\fR gives the name of a file that is to be read to supply data
55
for the photo image.  The file format must be one of those for which
56
there is an image file format handler that can read data.
57
.TP
58
\fB\-gamma \fIvalue\fR
59
Specifies that the colors allocated for displaying this image in a
60
window should be corrected for a non-linear display with the specified
61
gamma exponent value.  (The intensity produced by most
62
CRT displays is a power function of the input value, to a good
63
approximation; gamma is the exponent and is typically around 2).
64
The value specified must be greater than zero.  The default
65
value is one (no correction).  In general, values greater than one
66
will make the image lighter, and values less than one will make it
67
darker.
68
.TP
69
\fB\-height \fInumber\fR
70
Specifies the height of the image, in pixels.  This option is useful
71
primarily in situations where the user wishes to build up the contents
72
of the image piece by piece.  A value of zero (the default) allows the
73
image to expand or shrink vertically to fit the data stored in it.
74
.TP
75
\fB\-palette \fIpalette-spec\fR
76
Specifies the resolution of the color cube to be allocated for
77
displaying this image, and thus the number of colors used from the
78
colormaps of the windows where it is displayed.  The
79
\fIpalette-spec\fR string may be either a single decimal number,
80
specifying the number of shades of gray to use, or three decimal
81
numbers separated by slashes (/), specifying the number of shades of
82
red, green and blue to use, respectively.  If the first form (a single
83
number) is used, the image will be displayed in monochrome (i.e.,
84
grayscale).
85
.TP
86
\fB\-width \fInumber\fR
87
Specifies the width of the image, in pixels.    This option is useful
88
primarily in situations where the user wishes to build up the contents
89
of the image piece by piece.  A value of zero (the default) allows the
90
image to expand or shrink horizontally to fit the data stored in it.
91
 
92
.SH "IMAGE COMMAND"
93
.PP
94
When a photo image is created, Tk also creates a new command
95
whose name is the same as the image.
96
This command may be used to invoke various operations
97
on the image.
98
It has the following general form:
99
.CS
100
\fIimageName option \fR?\fIarg arg ...\fR?
101
.CE
102
\fIOption\fR and the \fIarg\fRs
103
determine the exact behavior of the command.
104
.PP
105
Those options that write data to the image generally expand the size
106
of the image, if necessary, to accommodate the data written to the
107
image, unless the user has specified non-zero values for the
108
\fB\-width\fR and/or \fB\-height\fR configuration options, in which
109
case the width and/or height, respectively, of the image will not be
110
changed.
111
.PP
112
The following commands are possible for photo images:
113
.TP
114
\fIimageName \fBblank\fR
115
Blank the image; that is, set the entire image to have no data, so it
116
will be displayed as transparent, and the background of whatever
117
window it is displayed in will show through.
118
.TP
119
\fIimageName \fBcget\fR \fIoption\fR
120
Returns the current value of the configuration option given
121
by \fIoption\fR.
122
\fIOption\fR may have any of the values accepted by the
123
\fBimage create photo\fR command.
124
.TP
125
\fIimageName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
126
Query or modify the configuration options for the image.
127
If no \fIoption\fR is specified, returns a list describing all of
128
the available options for \fIimageName\fR (see \fBTk_ConfigureInfo\fR for
129
information on the format of this list).  If \fIoption\fR is specified
130
with no \fIvalue\fR, then the command returns a list describing the
131
one named option (this list will be identical to the corresponding
132
sublist of the value returned if no \fIoption\fR is specified).  If
133
one or more \fIoption\-value\fR pairs are specified, then the command
134
modifies the given option(s) to have the given value(s);  in
135
this case the command returns an empty string.
136
\fIOption\fR may have any of the values accepted by the
137
\fBimage create photo\fR command.
138
.TP
139
\fIimageName \fBcopy\fR \fIsourceImage\fR ?\fIoption value(s) ...\fR?
140
Copies a region from the image called \fIsourceImage\fR (which must
141
be a photo image) to the image called \fIimageName\fR, possibly with
142
pixel zooming and/or subsampling.  If no options are specified, this
143
command copies the whole of \fIsourceImage\fR into \fIimageName\fR,
144
starting at coordinates (0,0) in \fIimageName\fR.  The following
145
options may be specified:
146
.RS
147
.TP
148
\fB\-from \fIx1 y1 x2 y2\fR
149
Specifies a rectangular sub-region of the source image to be copied.
150
(\fIx1,y1\fR) and (\fIx2,y2\fR) specify diagonally opposite corners of
151
the rectangle.  If \fIx2\fR and \fIy2\fR are not specified, the
152
default value is the bottom-right corner of the source image.  The
153
pixels copied will include the left and top edges of the specified
154
rectangle but not the bottom or right edges.  If the \fB\-from\fR
155
option is not given, the default is the whole source image.
156
.TP
157
\fB\-to \fIx1 y1 x2 y2\fR
158
Specifies a rectangular sub-region of the destination image to be
159
affected.  (\fIx1,y1\fR) and (\fIx2,y2\fR) specify diagonally opposite
160
corners of the rectangle.  If \fIx2\fR and \fIy2\fR are not specified,
161
the default value is (\fIx1,y1\fR) plus the size of the source
162
region (after subsampling and zooming, if specified).  If \fIx2\fR and
163
\fIy2\fR are specified, the source region will be replicated if
164
necessary to fill the destination region in a tiled fashion.
165
.TP
166
\fB\-shrink\fR
167
Specifies that the size of the destination image should be reduced, if
168
necessary, so that the region being copied into is at the bottom-right
169
corner of the image.  This option will not affect the width or height
170
of the image if the user has specified a non-zero value for the
171
\fB\-width\fR or \fB\-height\fR configuration option, respectively.
172
.TP
173
\fB\-zoom \fIx y\fR
174
Specifies that the source region should be magnified by a factor of
175
\fIx\fR in the X direction and \fIy\fR in the Y direction.  If \fIy\fR
176
is not given, the default value is the same as \fIx\fR.  With this
177
option, each pixel in the source image will be expanded into a block
178
of \fIx\fR x \fIy\fR pixels in the destination image, all the same
179
color.  \fIx\fR and \fIy\fR must be greater than 0.
180
.TP
181
\fB\-subsample \fIx y\fR
182
Specifies that the source image should be reduced in size by using
183
only every \fIx\fRth pixel in the X direction and \fIy\fRth pixel in
184
the Y direction.  Negative values will cause the image to be flipped
185
about the Y or X axes, respectively.  If \fIy\fR is not given, the
186
default value is the same as \fIx\fR.
187
.RE
188
.TP
189
\fIimageName \fBget\fR \fIx y\fR
190
Returns the color of the pixel at coordinates (\fIx\fR,\fIy\fR) in the
191
image as a list of three integers between 0 and 255, representing the
192
red, green and blue components respectively.
193
.TP
194
\fIimageName \fBput \fIdata\fR ?\fB\-to\fI x1 y1 x2 y2\fR?
195
Sets pixels in \fIimageName\fR to the colors specified in \fIdata\fR.
196
\fIdata\fR is used to form a two-dimensional array of pixels that are
197
then copied into the \fIimageName\fR.  \fIdata\fR is structured as a
198
list of horizontal rows, from top to bottom, each of which is a list
199
of colors, listed from left to right.  Each color may be specified by name
200
(e.g., blue) or in hexadecimal form (e.g., #2376af).  The
201
\fB\-to\fR option can be used to specify the area of \fIimageName\fR to be
202
affected.  If only \fIx1\fR and \fIy1\fR are given, the area affected
203
has its top-left corner at (\fIx1,y1\fR) and is the same size as the
204
array given in \fIdata\fR.  If all four coordinates are given, they
205
specify diagonally opposite corners of the affected rectangle, and the
206
array given in \fIdata\fR will be replicated as necessary in the X and
207
Y directions to fill the rectangle.
208
.TP
209
\fIimageName \fBread\fR \fIfilename\fR ?\fIoption value(s) ...\fR?
210
Reads image data from the file named \fIfilename\fR into the image.
211
This command first searches the list of
212
image file format handlers for a handler that can interpret the data
213
in \fIfilename\fR, and then reads the image in \fIfilename\fR into
214
\fIimageName\fR (the destination image).  The following options may be
215
specified:
216
.RS
217
.TP
218
\fB\-format \fIformat-name\fR
219
Specifies the format of the image data in \fIfilename\fR.
220
Specifically, only image file format handlers whose names begin with
221
\fIformat-name\fR will be used while searching for an image data
222
format handler to read the data.
223
.TP
224
\fB\-from \fIx1 y1 x2 y2\fR
225
Specifies a rectangular sub-region of the image file data to be copied
226
to the destination image.  If only \fIx1\fR and \fIy1\fR are
227
specified, the region extends from (\fIx1,y1\fR) to the bottom-right
228
corner of the image in the image file.  If all four coordinates are
229
specified, they specify diagonally opposite corners or the region.
230
The default, if this option is not specified, is the whole of the
231
image in the image file.
232
.TP
233
\fB\-shrink\fR
234
If this option, the size of \fIimageName\fR will be reduced, if
235
necessary, so that the region into which the image file data are read
236
is at the bottom-right corner of the \fIimageName\fR.  This option
237
will not affect the width or height of the image if the user has
238
specified a non-zero value for the \fB\-width\fR or \fB\-height\fR
239
configuration option, respectively.
240
.TP
241
\fB\-to \fIx y\fR
242
Specifies the coordinates of the top-left corner of the region of
243
\fIimageName\fR into which data from \fIfilename\fR are to be read.
244
The default is (0,0).
245
.RE
246
.TP
247
\fIimageName \fBredither\fR
248
The dithering algorithm used in displaying photo images propagates
249
quantization errors from one pixel to its neighbors.
250
If the image data for \fIimageName\fR is supplied in pieces, the
251
dithered image may not be exactly correct.  Normally the difference is
252
not noticeable, but if it is a problem, this command can be used to
253
recalculate the dithered image in each window where the image is
254
displayed.
255
.TP
256
\fIimageName \fBwrite \fIfilename\fR ?\fIoption value(s) ...\fR?
257
Writes image data from \fIimageName\fR to a file named \fIfilename\fR.
258
The following options may be specified:
259
.RS
260
.TP
261
\fB\-format\fI format-name\fR
262
Specifies the name of the image file format handler to be used to
263
write the data to the file.  Specifically, this subcommand searches
264
for the first handler whose name matches a initial substring of
265
\fIformat-name\fR and which has the capability to write an image
266
file.  If this option is not given, this subcommand uses the first
267
handler that has the capability to write an image file.
268
.TP
269
\fB\-from \fIx1 y1 x2 y2\fR
270
Specifies a rectangular region of \fIimageName\fR to be written to the
271
image file.  If only \fIx1\fR and \fIy1\fR are specified, the region
272
extends from \fI(x1,y1)\fR to the bottom-right corner of
273
\fIimageName\fR.  If all four coordinates are given, they specify
274
diagonally opposite corners of the rectangular region.  The default,
275
if this option is not given, is the whole image.
276
.RE
277
.SH "IMAGE FORMATS"
278
.PP
279
The photo image code is structured to allow handlers for additional
280
image file formats to be added easily.  The photo image code maintains
281
a list of these handlers.  Handlers are added to the list by
282
registering them with a call to \fBTk_CreatePhotoImageFormat\fR.  The
283
standard Tk distribution comes with handlers for PPM/PGM and GIF formats,
284
which are automatically registered on initialization.
285
.PP
286
When reading an image file or processing
287
string data specified with the \fB\-data\fR configuration option, the
288
photo image code invokes each handler in turn until one is
289
found that claims to be able to read the data in the file or string.
290
Usually this will find the correct handler, but if it doesn't, the
291
user may give a format name with the \fB\-format\fR option to specify
292
which handler to use.  In fact the photo image code will try those
293
handlers whose names begin with the string specified for the
294
\fB\-format\fR option (the comparison is case-insensitive).  For
295
example, if the user specifies \fB\-format gif\fR, then a handler
296
named GIF87 or GIF89 may be invoked, but a handler
297
named JPEG may not (assuming that such handlers had been
298
registered).
299
.PP
300
When writing image data to a file, the processing of the
301
\fB\-format\fR option is slightly different: the string value given
302
for the \fB\-format\fR option must begin with the complete name of the
303
requested handler, and may contain additional information following
304
that, which the handler can use, for example, to specify which variant
305
to use of the formats supported by the handler.
306
 
307
.SH "COLOR ALLOCATION"
308
.PP
309
When a photo image is displayed in a window, the photo image code
310
allocates colors to use to display the image and dithers the image, if
311
necessary, to display a reasonable approximation to the image using
312
the colors that are available.  The colors are allocated as a color
313
cube, that is, the number of colors allocated is the product of the
314
number of shades of red, green and blue.
315
.PP
316
Normally, the number of
317
colors allocated is chosen based on the depth of the window.  For
318
example, in an 8-bit PseudoColor window, the photo image code will
319
attempt to allocate seven shades of red, seven shades of green and
320
four shades of blue, for a total of 198 colors.  In a 1-bit StaticGray
321
(monochrome) window, it will allocate two colors, black and white.  In
322
a 24-bit DirectColor or TrueColor window, it will allocate 256 shades
323
each of red, green and blue.  Fortunately, because of the way that
324
pixel values can be combined in DirectColor and TrueColor windows,
325
this only requires 256 colors to be allocated.  If not all of the
326
colors can be allocated, the photo image code reduces the number of
327
shades of each primary color and tries again.
328
.PP
329
The user can exercise some control over the number of colors that a
330
photo image uses with the \fB\-palette\fR configuration option.  If
331
this option is used, it specifies the maximum number of shades of
332
each primary color to try to allocate.  It can also be used to force
333
the image to be displayed in shades of gray, even on a color display,
334
by giving a single number rather than three numbers separated by
335
slashes.
336
 
337
.SH CREDITS
338
.PP
339
The photo image type was designed and implemented by Paul Mackerras,
340
based on his earlier photo widget and some suggestions from
341
John Ousterhout.
342
 
343
.SH KEYWORDS
344
photo, image, color

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.