.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Image 3" .TH Image 3 2023-07-25 "perl v5.38.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Tk::Image \- Create and manipulate images .SH SYNOPSIS .IX Header "SYNOPSIS" \&\fR\f(CI$image\fR\fI\fR = \fI\fR\f(CI$widget\fR\fI\fR\->\fItype\fR(?\fIarg arg ...\fR?) .PP \&\fR\f(CI$image\fR\fI\fR\->\fImethod\fR(?\fIarg arg ...\fR?) .SH DESCRIPTION .IX Header "DESCRIPTION" The \fBimage\fR constructors and methods are used to create, delete, and query images. It can take several different forms, depending on the \&\fItype\fR. .PP The constructors require a \fR\f(CI$widget\fR\fI\fR to invoke them, this is used to locate a \fBMainWindow\fR. (This is because the underlying Tk code registers the images in the data structure for the \fBMainWindow\fR.) .PP The legal forms are: .ie n .IP "\fR\fI$widget\fR\fI\fR\->\fItype\fR?(?\fIname\fR?,?\fIoption\fR=>\fIvalue ...\fR)?" 4 .el .IP "\fR\f(CI$widget\fR\fI\fR\->\fItype\fR?(?\fIname\fR?,?\fIoption\fR=>\fIvalue ...\fR)?" 4 .IX Item "$widget->type?(?name?,?option=>value ...)?" Creates a new image and returns an object. \&\fItype\fR specifies the type of the image, which must be one of the types currently defined (e.g., \fBBitmap\fR). \&\fIname\fR specifies the name for the image; if it is omitted then Tk picks a name of the form \fBimage\fR\fIx\fR, where \fIx\fR is an integer. There may be any number of \fIoption\fR=>\fIvalue\fR 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. .ie n .IP \fR\fI$image\fR\fI\fR\->\fBdelete\fR 4 .el .IP \fR\f(CI$image\fR\fI\fR\->\fBdelete\fR 4 .IX Item "$image->delete" Deletes the image \fR\f(CI$image\fR\fI\fR 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 \fIname\fR) the existing instances will use the new image. .ie n .IP \fR\fI$image\fR\fI\fR\->\fBheight\fR 4 .el .IP \fR\f(CI$image\fR\fI\fR\->\fBheight\fR 4 .IX Item "$image->height" Returns a decimal string giving the height of image \fIname\fR in pixels. .ie n .IP \fR\fI$image\fR\fI\fR\->\fBinuse\fR 4 .el .IP \fR\f(CI$image\fR\fI\fR\->\fBinuse\fR 4 .IX Item "$image->inuse" Returns a boolean value indicating whether or not the image is in use by any widgets. .ie n .IP \fR\fI$widget\fR\fI\fR\->\fBimageNames\fR 4 .el .IP \fR\f(CI$widget\fR\fI\fR\->\fBimageNames\fR 4 .IX Item "$widget->imageNames" Returns a list containing all existing images for \fR\f(CI$widget\fR\fI\fR's \&\fBMainWindow\fR. .ie n .IP \fR\fI$image\fR\fI\fR\->\fBtype\fR 4 .el .IP \fR\f(CI$image\fR\fI\fR\->\fBtype\fR 4 .IX Item "$image->type" Returns the type of \fR\f(CI$image\fR\fI\fR (the value of the \fItype\fR method when the image was created). .ie n .IP \fR\fI$widget\fR\fI\fR\->\fBimageTypes\fR 4 .el .IP \fR\f(CI$widget\fR\fI\fR\->\fBimageTypes\fR 4 .IX Item "$widget->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 \fItype\fR to create an image). .ie n .IP \fR\fI$image\fR\fI\fR\->\fBwidth\fR 4 .el .IP \fR\f(CI$image\fR\fI\fR\->\fBwidth\fR 4 .IX Item "$image->width" Returns a decimal string giving the width of image \fIname\fR in pixels. .SH "BUILT-IN IMAGE TYPES" .IX Header "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. .IP \fBBitmap\fR 4 .IX Item "Bitmap" Each pixel in the image displays a foreground color, a background color, or nothing. See Tk::Bitmap for more information. .IP \fBPixmap\fR 4 .IX Item "Pixmap" \&\fBPixmap\fR is slightly more general than \fBBitmap\fR, each pixel can be any available color or "transparent" (rendered as background color of the widget image is displayed in). \fBPixmap\fR is best used for icons and other simple graphics with only a few colors. .Sp \&\fBPixmap\fR is derived from Tix. See Tk::Pixmap for more information. .IP \fBPhoto\fR 4 .IX Item "Photo" Displays a variety of full-color images, using dithering to approximate colors on displays with limited color capabilities. See Tk::Photo documentation for more information. .SH CAVEATS .IX Header "CAVEATS" It's necessary to use the "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 \f(CW\*(C`undef\*(C'\fR is not sufficient. .SH "SEE ALSO" .IX Header "SEE ALSO" Tk::Bitmap Tk::Pixmap Tk::Photo .SH KEYWORDS .IX Header "KEYWORDS" height, image, types of images, width