81 lines
2.5 KiB

'\" Color=Green
.so STk-man.macros
.TH make-image n 3.2 STk "STk procedure"
'\" Note: do not modify the .SH NAME line immediately below!
create\-image, find\-image, change\-image, free\-image \- an easier way to manipulate Tk images
(\fBmake-image\fR key \fIcreate image ?options?\fR)
(\fBfind-image\fR key)
(\fBchange-image\fR key \fIcreate image options\fR)
(\fBfree-image\fR key)
\fBmake-image\fR is a STk procedure which simplifies Tk images
creation by providing a homogeneous way to create an image,
independently of its coding format. The first argument of
\fBmake-image\fR is a string which identifies the image; if an image
with this key has been already loaded in memory, it will not be loaded
again and \fBmake-image\fR will return it. If no option is given,
the identifying image key is taken as a file name (the file is searched
using the variable \fB*image\-path*\fR, which must contain a set of
prefix pathnames to prepend to the given filename).
If options are passed to the \fBmake-image\fR procedure they must follow
the convention of the options passed in \fBimage create\fR just after the
image format. If the image cannot be created, this procedure returns \fB#f\fR.
Hereafter is a simple usage of this procedure:
(require "image")
(require "pixmap")
(define img1 (make-image "a pixmap" :file "exit.xpm"))
(define img2 (make-image "a bitmap" :file "default.xbm"))
(define img3 (make-image "a pixmap"))
(define img4 (make-image "x.xpm"))
In this case, \fIimg3\fR is identical to \fIimg1\fR since they use the same key.
\fIImg4\fR is the image associated to the file "x.xpm" found according to
the *image-path* varaiable.
\fBfind-image\fR returns the image associated to the given \fIkey\fR or
\fB#f\fR if this image has not been loaded yet.
\fBchange-image\fR changes the content of an image previously created with
\fBmake-image\fR. Options are the identical to \fBmake-image\fR
(button '.b1 :image img1)
(button '.b2 :image img2)
(button '.b3 :image img1) ; .b3 content is identical to .b1
(pack .b1 .b2 .b3)
(change-image "a pixmap" :file "default.xbm")
After the execution of \fBchange-image\fR, both \fI.b1\fR and \fI.b3\fR
graphical contents are changed.
\fBdelete-image\fR removes the image with the given key of the cache.
The memory used by this image is returned to the system. See the
discussion about how this image is displayed in \fBimage delete\fR.
bitmap, image, jpeg, photo, pixmap