summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Tk/Image.pod
blob: 9a9b6b6b646b8151c5f8e1889e50e28c5713cc08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#  Copyright (c) 1994 The Regents of the University of California.
#  Copyright (c) 1994-1996 Sun Microsystems, Inc.
#  See the file "license.terms" for information on usage and redistribution
#  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
#

=head1 NAME

Tk::Image - Create and manipulate images

=for category  Tk Image Classes

=head1 SYNOPSIS

I<$image> = I<$widget>-E<gt>I<type>(?I<arg arg ...>?)

I<$image>-E<gt>I<method>(?I<arg arg ...>?)

=head1 DESCRIPTION

The B<image> constructors and methods are used to create, delete, and query images.
It can take several different forms, depending on the
I<type>.

The constructors require a I<$widget> to invoke them, this is used
to locate a B<MainWindow>. (This is because the underlying Tk code
registers the images in the data structure for the B<MainWindow>.)

The legal forms are:

=over 4

=item I<$widget>-E<gt>I<type>?(?I<name>?,?I<option>=E<gt>I<value ...>)?

Creates a new image and returns an object.
I<type> specifies the type of the image, which must be one of
the types currently defined (e.g., B<Bitmap>).
I<name> specifies the name for the image;  if it is omitted then
Tk picks a name of the form B<image>I<x>, where I<x> is
an integer.
There may be any number of I<option>=E<gt>I<value> pairs,
which provide configuration options for the new image.
The legal set of options is defined separately for each image
type;  see below for details on the options for built-in image types.
If an image already exists by the given name then it is replaced
with the new image and any instances of that image will redisplay
with the new contents.

=item I<$image>-E<gt>B<delete>

Deletes the image I<$image> and returns an empty string.
If there are instances of the image displayed in widgets,
the image won't actually be deleted until all of the instances
are released.
However, the association between the instances and the image
manager will be dropped.
Existing instances will retain their sizes but redisplay as
empty areas.
If a deleted image is recreated (with the same I<name>)
the existing instances will use the new image.

=item I<$image>-E<gt>B<height>

Returns a decimal string giving the height of image I<name>
in pixels.

=item I<$widget>-E<gt>B<imageInuse>( 'name' );

Returns  a  boolean  value  indicating  whether or not the image
given by I<name> is in use by any widgets.

=item I<$widget>-E<gt>B<imageNames>

Returns a list containing all existing images for I<$widget>'s
B<MainWindow>.

=item I<$image>-E<gt>B<type>

Returns the type of  I<$image> (the value of the I<type>
method when the image was created).

=item I<$widget>-E<gt>B<imageTypes>

Returns a list whose elements are all of the valid image types
(i.e., all of the values that may be supplied for the I<type>
to create an image).

=item I<$image>-E<gt>B<width>

Returns a decimal string giving the width of image I<name>
in pixels.

=back

=head1 BUILT-IN IMAGE TYPES

The following image types are defined by Tk so they will be available
in any Tk application.
Individual applications or extensions may define additional types.

=over 4

=item B<Bitmap>

Each pixel in the image displays a foreground color, a background
color, or nothing.
See L<Tk::Bitmap> for more information.

=item B<Pixmap>

B<Pixmap> is slightly more general than B<Bitmap>, each pixel can
be any available color or "transparent" (rendered as background color of the
widget image is displayed in). B<Pixmap> is best used for icons and other
simple graphics with only a few colors.

B<Pixmap> is derived from Tix. See L<Tk::Pixmap> for more information.

=item B<Photo>

Displays a variety of full-color images, using dithering to
approximate colors on displays with limited color capabilities.
See L<Tk::Photo> documentation for more information.

=back

=head1 CAVEATS

It's necessary to use the L</delete> method to delete an image object
and free memory associated with it. Just using a lexical variable for
storing the image object and letting the variable to go out of scope
or setting to C<undef> is not sufficient.

=head1 SEE ALSO

L<Tk::Bitmap|Tk::Bitmap>
L<Tk::Pixmap|Tk::Pixmap>
L<Tk::Photo|Tk::Photo>

=head1 KEYWORDS

height, image, types of images, width

=cut