2 '\" Copyright (c) 1994 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 .TH Tk_GetImage 3 4.0 Tk "Tk Library Procedures"
14 Tk_GetImage, Tk_RedrawImage, Tk_SizeOfImage, Tk_FreeImage \- use an image in a widget
20 \fBTk_GetImage\fR(\fIinterp, tkwin, name, changeProc, clientData\fR)
22 \fBTk_RedrawImage\fR(\fIimage, imageX, imageY, width, height, drawable, drawableX, drawableY\fR)
24 \fBTk_SizeOfImage\fR(\fIimage, widthPtr, heightPtr\fR)
26 \fBTk_FreeImage\fR(\fIimage\fR)
28 .AS Tk_ImageChangedProc *changeProc
29 .AP Tcl_Interp *interp in
30 Place to leave error message.
31 .AP Tk_Window tkwin in
32 Window in which image will be used.
35 .AP Tk_ImageChangedProc *changeProc in
36 Procedure for Tk to invoke whenever image content or size changes.
37 .AP ClientData clientData in
38 One-word value for Tk to pass to \fIchangeProc\fR.
40 Token for image instance; must have been returned by a previous
41 call to \fBTk_GetImage\fR.
43 X-coordinate of upper-left corner of region of image to redisplay
44 (measured in pixels from the image's upper-left corner).
46 Y-coordinate of upper-left corner of region of image to redisplay
47 (measured in pixels from the image's upper-left corner).
49 Width of region of image to redisplay.
51 Height of region of image to redisplay.
52 .AP Drawable drawable in
53 Where to display image. Must either be window specified to
54 \fBTk_GetImage\fR or a pixmap compatible with that window.
56 Where to display image in \fIdrawable\fR: this is the x-coordinate
57 in \fIdrawable\fR where x-coordinate \fIimageX\fR of the image
60 Where to display image in \fIdrawable\fR: this is the y-coordinate
61 in \fIdrawable\fR where y-coordinate \fIimageY\fR of the image
63 .AP "int" widthPtr out
64 Store width of \fIimage\fR (in pixels) here.
65 .AP "int" heightPtr out
66 Store height of \fIimage\fR (in pixels) here.
71 These procedures are invoked by widgets that wish to display images.
72 \fBTk_GetImage\fR is invoked by a widget when it first decides to
74 \fIname\fR gives the name of the desired image and \fItkwin\fR
75 identifies the window where the image will be displayed.
76 \fBTk_GetImage\fR looks up the image in the table of existing
77 images and returns a token for a new instance of the image.
78 If the image doesn't exist then \fBTk_GetImage\fR returns NULL
79 and leaves an error message in \fIinterp->result\fR.
81 When a widget wishes to actually display an image it must
82 call \fBTk_RedrawImage\fR, identifying the image (\fIimage\fR),
83 a region within the image to redisplay (\fIimageX\fR, \fIimageY\fR,
84 \fIwidth\fR, and \fIheight\fR), and a place to display the
85 image (\fIdrawable\fR, \fIdrawableX\fR, and \fIdrawableY\fR).
86 Tk will then invoke the appropriate image manager, which will
87 display the requested portion of the image before returning.
89 A widget can find out the dimensions of an image by calling
90 \fBTk_SizeOfImage\fR: the width and height will be stored
91 in the locations given by \fIwidthPtr\fR and \fIheightPtr\fR,
94 When a widget is finished with an image (e.g., the widget is
95 being deleted or it is going to use a different image instead
96 of the current one), it must call \fBTk_FreeImage\fR to
97 release the image instance.
98 The widget should never again use the image token after passing
99 it to \fBTk_FreeImage\fR.
100 There must be exactly one call to \fBTk_FreeImage\fR for each
101 call to \fBTk_GetImage\fR.
103 If the contents or size of an image changes, then any widgets
104 using the image will need to find out about the changes so that
105 they can redisplay themselves.
106 The \fIchangeProc\fR and \fIclientData\fR arguments to
107 \fBTk_GetImage\fR are used for this purpose.
108 \fIchangeProc\fR will be called by Tk whenever a change occurs
109 in the image; it must match the following prototype:
111 typedef void Tk_ImageChangedProc(
112 ClientData \fIclientData\fR,
117 int \fIimageWidth\fR,
118 int \fIimageHeight\fR);
120 The \fIclientData\fR argument to \fIchangeProc\fR is the same as the
121 \fIclientData\fR argument to \fBTk_GetImage\fR.
122 It is usually a pointer to the widget record for the widget or
123 some other data structure managed by the widget.
124 The arguments \fIx\fR, \fIy\fR, \fIwidth\fR, and \fIheight\fR
125 identify a region within the image that must be redisplayed;
126 they are specified in pixels measured from the upper-left
128 The arguments \fIimageWidth\fR and \fIimageHeight\fR give
129 the image's (new) size.