USEFUL TCL UTILITIES
Capture
Display Window to An Image. The Tcl command rimage
window calculates various window geometries and captures a whole
or a part of display window into an image, which can be either saved into
a disk file or put into clipboard or used directly as an input of a Tk
image (i.e., gimg). Its usage
is described as follows
rimage window imgID ?option?
This command performs functions associated to a window
(screen) related bitmap depending on the parameter, imgID, which
may refers to either a Tk window or a memory-resident rimage or the system's
clipboard. When the command is invoked, it first checks what the imgID
refers to.
There are three cases of the imgID. In the
first case, the imgID referes to an existing Tk window, i.e., a
window's pathname. This command returns the window' geometry in a list,
i.e., {x0 y0 width height}. In this case the ?option? in the command
line can be either frame, rect, clip or their combinations
separated by either a "," or a "|", or a " ". An option of frame
means the toplevel window's outside frame geometry based on the screen's
coordinates. An option of rect (default) means the window's client
rectagle geometry, that is relative to the toplevel's outside frame. An
option of clip means the clipping geometry within the virtual display
screen. A combination of frame and rect (i.e., frame|rect)
means the window's geometry should be calculated based on the virtural
screen coordinate system. For examples:
% wm geom .
200x200+1124+15
% rimage window . frame
1124 15 208 232
% rimage window . rect
4 28 200 200
% rimage window . clip
0 0 1280 1024
% rimage window . frame|rect
1128 43 200 200
% rimage window . frame|rect|clip
1128 43 152 200
In the second case, the imgID is a literal clipboard,
this command crops the screen bitmap into the system's clipboard.
For example,
rimage window clipboard
will capture the whole screen into a bitmap and puts it into
the clipboard.
In the third case, the imgID will be considered
an ID of a memory-resident rimage. In this case, the command captures the
bitmap contents of the display screen into a memory-resident rimage
identified by imgID. If the rimage does not exists, it will be created;
if it alreadly exists, it will be updated. In both the second and third
cases, the area of the contents within the display screen may be specified
by ?option?, which defines the geometry of the bitmap on the screen.
The geometry definition may be either a Tk window's path or a list
of {x0 y0 width height}, where x0 and y0 define the
coordinates of the upper left conner; width and height define
the demension sizes of the area. If the geometry is defined by a Tk window,
it is equivalent to the geometry calculated by rimage window path
frame|rect|clip.
rimage window imgID path
rimage window imgID [rimage windowpathframe|rect|clilp]
Application Notes: a memory-resident rimage will lost
when wish or the xbit application is closed. A user
can use rimage crop or rimage copy command to save the memory-resident
rimage into a disk file.
Capture
Canvas to An Image. The Tcl command rimage
canvas captures the drawing of a Tk canvas into an image, which
can be either saved into a disk file or put into clipboard or used directly
as an input of a Tk image (i.e, gimg).
Its usage is described as follows
rimage canvas canvasID rimageID
?x0 y0 width height? ?coordType?
This command captures the contents of a canvas identified
by canvasID into a memory-resident rimage identified by rimageID.
The x0 y0 width height specify a region of interest in either screen
coordinate or drawable coordinates, which is defined by coordType
with 0 for screen coordinates and 1 for drawable coordiantes.. The
default value for coordType is 0. If the rimageID is
a literal
clipboard, the captured bitmap will be put into the system
clipboard.
Application Notes: this command will capture the
drawing of canvas items except for window items. A canvas to be catpured
may be either displayed or covered or iconified. This command works
for both Tk canvas and XBit's gcanvas.
Capture
Canvas to a Meta File. The Tcl command
gmetafile
canvas captures the drawing of a Tk canvas into a Windows metafile.
Its usage is described as follows.
gmetafile canvasPathname metaFileName
?x0 y0 x1 y1? ?coordType?
This command draws the canvas contents into a Windows
meta file. The canvas contents may be clipped within an area defined
by x0 y0 x1 y1. The coordType specifies the type of coordinate,
0 for screen coordinates and 1 for drawable coordinates. The default
value for coordType is 0. If the metaFileName is a litteral
clipboard,
the created meta file will be put into the Windows clipboard.
Application Notes: this command will capture the
drawing of canvas items except for window items. A canvas to be catpured
may be either displayed or covered or iconified. This command works
for both Tk canvas and XBit's gcanvas.
Printer
API for Windows. The Tcl command printer
is an API for applications to print Tk widgets, to select a printer device
and set up a page layout for printing. Currently, it only supports to print
canvas widget and is available to Windows. The following commands
are available:
printer enum level ?options?
This command enumerates available printers. Level
can be 1, 2, 4 and 5. Available options are default, remote,
shared,
favorite,
and local. If more than one options are used, they must be
separated with a space.
printer canvas pathname ?scale? ?x0 y0
x1 y1? ?coordType? ?driveName deviceName portName?
This command prints the canvas contents which may be
scaled with a scale and sub-set within a range defined by x0 y0 x1 y1.
The coordType specifies the type of coordinate, 0 for screen coordinates
and 1 for drawable coordinates. The default value for coordType is
0. A user can also choose a printer other than the default by specifying
the drive name, device name and port name. The default scale, a zero
or negative scale is to fit the contents to a page's margins.
printer capability ?driveName deviceName portName?
This command retrieves the capabilities of the current
printer device. A printer other than the current may be specified
by options ?drivename deviceName portName?
printer interactive ?option?
This command sets up the flag of interactive printing.
If the option is set to 1, a printer dialog will pop up before pirnting
so a user may choose pages, copies and etc. If no opiotn is
given, this command returns the currrent flag value.
printer setup ?ownerwindow?
This command pops up a dialog box to set up the current
printer. The default ownerwindow is the main window.
printer pagesetup ?ownerwindow?
This command sets up a printer and its page layout of
a printer. The default ownerwindow is the main window.
[HOME][CONTENTS][DOWNLOAD] |
|