1Image(3) User Contributed Perl Documentation Image(3)
2
3
4
6 Tk::Image - Create and manipulate images
7
9 $image = $widget->type(?arg arg ...?)
10
11 $image->method(?arg arg ...?)
12
14 The image constructors and methods are used to create, delete, and
15 query images. It can take several different forms, depending on the
16 type.
17
18 The constructors require a $widget to invoke them, this is used to
19 locate a MainWindow. (This is because the underlying Tk code registers
20 the images in the data structure for the MainWindow.)
21
22 The legal forms are:
23
24 $widget->type?(?name?,?option=>value ...)?
25 Creates a new image and returns an object. type specifies the type
26 of the image, which must be one of the types currently defined
27 (e.g., Bitmap). name specifies the name for the image; if it is
28 omitted then Tk picks a name of the form imagex, where x is an
29 integer. There may be any number of option=>value pairs, which
30 provide configuration options for the new image. The legal set of
31 options is defined separately for each image type; see below for
32 details on the options for built-in image types. If an image
33 already exists by the given name then it is replaced with the new
34 image and any instances of that image will redisplay with the new
35 contents.
36
37 $image->delete
38 Deletes the image $image and returns an empty string. If there are
39 instances of the image displayed in widgets, the image won't
40 actually be deleted until all of the instances are released.
41 However, the association between the instances and the image
42 manager will be dropped. Existing instances will retain their
43 sizes but redisplay as empty areas. If a deleted image is
44 recreated (with the same name) the existing instances will use the
45 new image.
46
47 $image->height
48 Returns a decimal string giving the height of image name in pixels.
49
50 $image->inuse
51 Returns a boolean value indicating whether or not the image is in
52 use by any widgets.
53
54 $widget->imageNames
55 Returns a list containing all existing images for $widget's
56 MainWindow.
57
58 $image->type
59 Returns the type of $image (the value of the type method when the
60 image was created).
61
62 $widget->imageTypes
63 Returns a list whose elements are all of the valid image types
64 (i.e., all of the values that may be supplied for the type to
65 create an image).
66
67 $image->width
68 Returns a decimal string giving the width of image name in pixels.
69
71 The following image types are defined by Tk so they will be available
72 in any Tk application. Individual applications or extensions may
73 define additional types.
74
75 Bitmap
76 Each pixel in the image displays a foreground color, a background
77 color, or nothing. See Tk::Bitmap for more information.
78
79 Pixmap
80 Pixmap is slightly more general than Bitmap, each pixel can be any
81 available color or "transparent" (rendered as background color of
82 the widget image is displayed in). Pixmap is best used for icons
83 and other simple graphics with only a few colors.
84
85 Pixmap is derived from Tix. See Tk::Pixmap for more information.
86
87 Photo
88 Displays a variety of full-color images, using dithering to
89 approximate colors on displays with limited color capabilities.
90 See Tk::Photo documentation for more information.
91
93 It's necessary to use the "delete" method to delete an image object and
94 free memory associated with it. Just using a lexical variable for
95 storing the image object and letting the variable to go out of scope or
96 setting to "undef" is not sufficient.
97
99 Tk::Bitmap Tk::Pixmap Tk::Photo
100
102 height, image, types of images, width
103
104
105
106perl v5.36.0 2022-07-22 Image(3)