2 '\" Copyright (c) 1994 The Australian National University
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.
8 '\" Author: Paul Mackerras (paulus@cs.anu.edu.au),
9 '\" Department of Computer Science,
10 '\" Australian National University.
12 '\" RCS: @(#) $Id: FindPhoto.3,v 1.3 1999/10/29 03:57:40 hobbs Exp $
14 '\" The definitions below are for supplemental macros used in Tcl/Tk
17 '\" .AP type name in/out ?indent?
18 '\" Start paragraph describing an argument to a library procedure.
19 '\" type is type of argument (int, etc.), in/out is either "in", "out",
20 '\" or "in/out" to describe whether procedure reads or modifies arg,
21 '\" and indent is equivalent to second arg of .IP (shouldn't ever be
22 '\" needed; use .AS below instead)
25 '\" Give maximum sizes of arguments for setting tab stops. Type and
26 '\" name are examples of largest possible arguments that will be passed
27 '\" to .AP later. If args are omitted, default tab stops are used.
30 '\" Start box enclosure. From here until next .BE, everything will be
31 '\" enclosed in one large box.
34 '\" End of box enclosure.
37 '\" Begin code excerpt.
42 '\" .VS ?version? ?br?
43 '\" Begin vertical sidebar, for use in marking newly-changed parts
44 '\" of man pages. The first argument is ignored and used for recording
45 '\" the version when the .VS was added, so that the sidebars can be
46 '\" found and removed when they reach a certain age. If another argument
47 '\" is present, then a line break is forced before starting the sidebar.
50 '\" End of vertical sidebar.
53 '\" Begin an indented unfilled display.
56 '\" End of indented unfilled display.
59 '\" Start of list of standard options for a Tk widget. The
60 '\" options follow on successive lines, in four columns separated
64 '\" End of list of standard options for a Tk widget.
66 '\" .OP cmdName dbName dbClass
67 '\" Start of description of a specific option. cmdName gives the
68 '\" option's name as specified in the class command, dbName gives
69 '\" the option's name in the option database, and dbClass gives
70 '\" the option's class in the option database.
73 '\" Print arg1 underlined, then print arg2 normally.
75 '\" RCS: @(#) $Id: man.macros,v 1.3 1999/04/16 00:46:35 stanton Exp $
77 '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
81 '\" # Start an argument description
85 . ie !"\\$2"" .TP \\n()Cu
90 \&\\$1 \\fI\\$2\\fP (\\$3)
103 '\" # define tabbing values for .AP
106 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
109 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
110 .nr )C \\n()Bu+\\w'(in/out)'u+2n
112 .AS Tcl_Interp Tcl_CreateInterp in/out
113 '\" # BS - start boxed text
114 '\" # ^y = starting y location
122 .if n \l'\\n(.lu\(ul'
125 '\" # BE - end boxed text (draw box now)
130 .ie n \l'\\n(^lu\(ul'
132 .\" Draw four-sided box normally, but don't draw top of
133 .\" box if the box started on an earlier page.
135 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
138 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
145 '\" # VS - start vertical sidebar
146 '\" # ^Y = starting y location
147 '\" # ^v = 1 (for troff; for nroff this doesn't matter)
151 .ie n 'mc \s12\(br\s0
154 '\" # VE - end of vertical sidebar
162 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
169 '\" # Special macro to handle page bottom: finish off current
170 '\" # box/sidebar if in box/sidebar mode, then invoked standard
171 '\" # page bottom macro.
178 .\" Draw three-sided box if this is the box's first page,
179 .\" draw two sides but no top otherwise.
180 .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
181 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
184 .nr ^x \\n(^tu+1v-\\n(^Yu
185 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
198 '\" # DS - begin display
204 '\" # DE - end display
210 '\" # SO - start of list of standard options
212 .SH "STANDARD OPTIONS"
218 '\" # SE - end of list of standard options
223 See the \\fBoptions\\fR manual entry for details on the standard options.
225 '\" # OP - start of full description for a single option
230 Command-Line Name: \\fB\\$1\\fR
231 Database Name: \\fB\\$2\\fR
232 Database Class: \\fB\\$3\\fR
236 '\" # CS - begin code excerpt
242 '\" # CE - end code excerpt
250 .TH Tk_FindPhoto 3 8.0 Tk "Tk Library Procedures"
253 Tk_FindPhoto, Tk_PhotoPutBlock, Tk_PhotoPutZoomedBlock, Tk_PhotoGetImage, Tk_PhotoBlank, Tk_PhotoExpand, Tk_PhotoGetSize, Tk_PhotoSetSize \- manipulate the image data stored in a photo image.
256 \fB#include <tk.h>\fR
257 \fB#include <tkPhoto.h>\fR
261 \fBTk_FindPhoto\fR(\fIinterp, imageName\fR)
265 \fBTk_PhotoPutBlock\fR(\fIhandle, blockPtr, x, y, width, height\fR)
268 \fBTk_PhotoPutZoomedBlock\fR(\fIhandle, blockPtr, x, y, width, height,\
269 zoomX, zoomY, subsampleX, subsampleY\fR)
272 \fBTk_PhotoGetImage\fR(\fIhandle, blockPtr\fR)
275 \fBTk_PhotoBlank\fR(\fIhandle\fR)
278 \fBTk_PhotoExpand\fR(\fIhandle, width, height\fR)
281 \fBTk_PhotoGetSize\fR(\fIhandle, widthPtr, heightPtr\fR)
284 \fBTk_PhotoSetSize\fR(\fIhandle, width, height\fR)
286 .AS Tk_PhotoImageBlock window_path
287 .AP Tcl_Interp *interp in
289 Interpreter in which image was created.
291 .AP char *imageName in
292 Name of the photo image.
293 .AP Tk_PhotoHandle handle in
294 Opaque handle identifying the photo image to be affected.
295 .AP Tk_PhotoImageBlock *blockPtr in
296 Specifies the address and storage layout of image data.
298 Specifies the X coordinate where the top-left corner of the block is
299 to be placed within the image.
301 Specifies the Y coordinate where the top-left corner of the block is
302 to be placed within the image.
304 Specifies the width of the image area to be affected (for
305 \fBTk_PhotoPutBlock\fR) or the desired image width (for
306 \fBTk_PhotoExpand\fR and \fBTk_PhotoSetSize\fR).
308 Specifies the height of the image area to be affected (for
309 \fBTk_PhotoPutBlock\fR) or the desired image height (for
310 \fBTk_PhotoExpand\fR and \fBTk_PhotoSetSize\fR).
311 .AP int *widthPtr out
312 Pointer to location in which to store the image width.
313 .AP int *heightPtr out
314 Pointer to location in which to store the image height.
315 .AP int subsampleX in
316 Specifies the subsampling factor in the X direction for input
318 .AP int subsampleY in
319 Specifies the subsampling factor in the Y direction for input
322 Specifies the zoom factor to be applied in the X direction to pixels
323 being written to the photo image.
325 Specifies the zoom factor to be applied in the Y direction to pixels
326 being written to the photo image.
331 \fBTk_FindPhoto\fR returns an opaque handle that is used to identify a
332 particular photo image to the other procedures. The parameter is the
333 name of the image, that is, the name specified to the \fBimage create
334 photo\fR command, or assigned by that command if no name was specified.
336 \fBTk_PhotoPutBlock\fR is used to supply blocks of image data to be
337 displayed. The call affects an area of the image of size
338 \fIwidth\fR x \fIheight\fR pixels, with its top-left corner at
339 coordinates (\fIx\fR,\fIy\fR). All of \fIwidth\fR, \fIheight\fR,
340 \fIx\fR, and \fIy\fR must be non-negative.
341 If part of this area lies outside the
342 current bounds of the image, the image will be expanded to include the
343 area, unless the user has specified an explicit image size with the
344 \fB\-width\fR and/or \fB\-height\fR widget configuration options
345 (see photo(n)); in that
346 case the area is silently clipped to the image boundaries.
348 The \fIblock\fR parameter is a pointer to a
349 \fBTk_PhotoImageBlock\fR structure, defined as follows:
352 unsigned char *\fIpixelPtr\fR;
358 } Tk_PhotoImageBlock;
360 The \fIpixelPtr\fR field points to the first pixel, that is, the
361 top-left pixel in the block.
362 The \fIwidth\fR and \fIheight\fR fields specify the dimensions of the
363 block of pixels. The \fIpixelSize\fR field specifies the address
364 difference between two horizontally adjacent pixels. Often it is 3
365 or 4, but it can have any value. The \fIpitch\fR field specifies the
366 address difference between two vertically adjacent pixels. The
367 \fIoffset\fR array contains the offsets from the address of a pixel
368 to the addresses of the bytes containing the red, green, blue and alpha
369 (transparency) components. These are normally 0, 1, 2 and 3, but can
370 have other values, e.g., for images that are stored as separate red,
371 green and blue planes.
373 The value given for the \fIwidth\fR and \fIheight\fR parameters to
374 \fBTk_PhotoPutBlock\fR do not have to correspond to the values specified
375 in \fIblock\fR. If they are smaller, \fBTk_PhotoPutBlock\fR extracts a
376 sub-block from the image data supplied. If they are larger, the data
377 given are replicated (in a tiled fashion) to fill the specified area.
378 These rules operate independently in the horizontal and vertical
381 \fBTk_PhotoPutZoomedBlock\fR works like \fBTk_PhotoPutBlock\fR except that
382 the image can be reduced or enlarged for display. The
383 \fIsubsampleX\fR and \fIsubsampleY\fR parameters allow the size of the
384 image to be reduced by subsampling.
385 \fBTk_PhotoPutZoomedBlock\fR will use only pixels from the input image
386 whose X coordinates are multiples of \fIsubsampleX\fR, and whose Y
387 coordinates are multiples of \fIsubsampleY\fR. For example, an image
388 of 512x512 pixels can be reduced to 256x256 by setting
389 \fIsubsampleX\fR and \fIsubsampleY\fR to 2.
391 The \fIzoomX\fR and \fIzoomY\fR parameters allow the image to be
392 enlarged by pixel replication. Each pixel of the (possibly subsampled)
393 input image will be written to a block \fIzoomX\fR pixels wide and
394 \fIzoomY\fR pixels high of the displayed image. Subsampling and
395 zooming can be used together for special effects.
397 \fBTk_PhotoGetImage\fR can be used to retrieve image data from a photo
398 image. \fBTk_PhotoGetImage\fR fills
399 in the structure pointed to by the \fIblockPtr\fR parameter with values
400 that describe the address and layout of the image data that the
401 photo image has stored internally. The values are valid
402 until the image is destroyed or its size is changed.
403 \fBTk_PhotoGetImage\fR returns 1 for compatibility with the
404 corresponding procedure in the old photo widget.
406 \fBTk_PhotoBlank\fR blanks the entire area of the
407 photo image. Blank areas of a photo image are transparent.
409 \fBTk_PhotoExpand\fR requests that the widget's image be expanded to be
410 at least \fIwidth\fR x \fIheight\fR pixels in size. The width and/or
411 height are unchanged if the user has specified an explicit image width
412 or height with the \fB\-width\fR and/or \fB\-height\fR configuration
413 options, respectively.
415 are being supplied in many small blocks, it is more efficient to use
416 \fBTk_PhotoExpand\fR or \fBTk_PhotoSetSize\fR at the beginning rather than
417 allowing the image to expand in many small increments as image blocks
420 \fBTk_PhotoSetSize\fR specifies the size of the image, as if the user
421 had specified the given \fIwidth\fR and \fIheight\fR values to the
422 \fB\-width\fR and \fB\-height\fR configuration options. A value of
423 zero for \fIwidth\fR or \fIheight\fR does not change the image's width
424 or height, but allows the width or height to be changed by subsequent
425 calls to \fBTk_PhotoPutBlock\fR, \fBTk_PhotoPutZoomedBlock\fR or
426 \fBTk_PhotoExpand\fR.
428 \fBTk_PhotoGetSize\fR returns the dimensions of the image in
429 *\fIwidthPtr\fR and *\fIheightPtr\fR.
433 The code for the photo image type was developed by Paul Mackerras,
434 based on his earlier photo widget code.