Tk_GetImage(3)
π NAME π
This is the Tk_GetImage(3) page from Tk Library Procedures, and itβs giving βuse an image in a widgetβ realness β iconic behavior only π
β¨
Tk_GetImage,Tk_RedrawImage,Tk_SizeOfImage,Tk_FreeImageβ use an image in a widget π
π¦ SYNOPSIS π¦
#include <tk.h>
Tk_Image
Tk_GetImage(interp, tkwin, name, changeProc, clientData)
Tk_RedrawImage(image, imageX, imageY, width, height, drawable, drawableX, drawableY)
Tk_SizeOfImage(image, widthPtr, heightPtr)
Tk_FreeImage(image)
π ARGUMENTS π
okay bestie, hereβs the cast β every type, every direction, every little detail, no cap:
Tcl_Interp *interp (in)β place to leave the error message.Tk_Window tkwin (in)β window in which image will be used.const char *name (in)β name of image.Tk_ImageChangedProc *changeProc (in)β procedure for Tk to invoke whenever image content or size changes.void *clientData (in)β one-word value for Tk to pass tochangeProc.Tk_Image image (in)β token for image instance; must have been returned by a previous call toTk_GetImage.int imageX (in)β X-coordinate of upper-left corner of region of image to redisplay (measured in pixels from the imageβs upper-left corner).int imageY (in)β Y-coordinate of upper-left corner of region of image to redisplay (measured in pixels from the imageβs upper-left corner).int width ((in))β width of region of image to redisplay.int height ((in))β height of region of image to redisplay.Drawable drawable (in)β where to display image. Must either be window specified toTk_GetImageor a pixmap compatible with that window.int drawableX (in)β where to display image indrawable: this is the x-coordinate indrawablewhere x-coordinateimageXof the image should be displayed.int drawableY (in)β where to display image indrawable: this is the y-coordinate indrawablewhere y-coordinateimageYof the image should be displayed.int widthPtr (out)β store width of image (in pixels) here.int heightPtr (out)β store height of image (in pixels) here.
π DESCRIPTION π
Okay so these procedures are invoked by widgets that wish to display images. Tk_GetImage is invoked by a widget when it first decides to display an image. name gives the name of the desired image and tkwin identifies the window where the image will be displayed. Tk_GetImage looks up the image in the table of existing images and returns a token for a new instance of the image. If the image does not exist then Tk_GetImage returns NULL and leaves an error message in interpreter interpβs result.
When a widget wishes to actually display an image it must call Tk_RedrawImage, identifying the image (image), a region within the image to redisplay (imageX, imageY, width, and height), and a place to display the image (drawable, drawableX, and drawableY). Tk will then invoke the appropriate image manager, which will display the requested portion of the image before returning.
A widget can find out the dimensions of an image by calling Tk_SizeOfImage: the width and height will be stored in the locations given by widthPtr and heightPtr, respectively.
When a widget is finished with an image (e.g., the widget is being deleted or it is going to use a different image instead of the current one), it must call Tk_FreeImage to release the image instance.
β οΈ bestie, listen: the widget should never again use the image token after passing it toTk_FreeImage. There must be exactly one call toTk_FreeImagefor each call toTk_GetImage. Thatβs the rule. π
If the contents or size of an image changes, then any widgets using the image will need to find out about the changes so that they can redisplay themselves. The changeProc and clientData arguments to Tk_GetImage are used for this purpose. changeProc will be called by Tk whenever a change occurs in the image; it must match the following prototype:
typedef void Tk_ImageChangedProc(
void *clientData,
int x,
int y,
int width,
int height,
int imageWidth,
int imageHeight);
The clientData argument to changeProc is the same as the clientData argument to Tk_GetImage. It is usually a pointer to the widget record for the widget or some other data structure managed by the widget. The arguments x, y, width, and height identify a region within the image that must be redisplayed; they are specified in pixels measured from the upper-left corner of the image. The arguments imageWidth and imageHeight give the imageβs (new) size.
π SEE ALSO π
Tk_CreateImageTypeβ the one and only reference here, iykyk β¨
β KEYWORDS β
imagesredisplay
okay bye bestie π«Ά β footer sign-off energy: source/version Tk 4.0, manual page Tk_GetImage(3), mwah πβ¨
π¦ where this page comes from
- alpine 3.23: tk9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tk9-doc 9.0.3-r2 Β· TCL
- fedora 43: tk-devel 1:9.0.2-1.fc43 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 43: tk-devel 1:9.0.2-1.fc43 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 44: tk-devel 1:9.0.2-1.fc44 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 44: tk-devel 1:9.0.2-1.fc44 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- nixos 26.05: tk 9.0.3
- nixpkgs unstable: tk 9.1.0
- Copyright (c) 1994 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms