Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | '\" |
2 | '\" Copyright (c) 1994 The Australian National University | |
3 | '\" Copyright (c) 1994-1997 Sun Microsystems, Inc. | |
4 | '\" | |
5 | '\" See the file "license.terms" for information on usage and redistribution | |
6 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. | |
7 | '\" | |
8 | '\" Author: Paul Mackerras (paulus@cs.anu.edu.au), | |
9 | '\" Department of Computer Science, | |
10 | '\" Australian National University. | |
11 | '\" | |
12 | '\" RCS: @(#) $Id: CrtPhImgFmt.3,v 1.5 2001/08/23 19:11:22 hobbs Exp $ | |
13 | '\" | |
14 | '\" The definitions below are for supplemental macros used in Tcl/Tk | |
15 | '\" manual entries. | |
16 | '\" | |
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) | |
23 | '\" | |
24 | '\" .AS ?type? ?name? | |
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. | |
28 | '\" | |
29 | '\" .BS | |
30 | '\" Start box enclosure. From here until next .BE, everything will be | |
31 | '\" enclosed in one large box. | |
32 | '\" | |
33 | '\" .BE | |
34 | '\" End of box enclosure. | |
35 | '\" | |
36 | '\" .CS | |
37 | '\" Begin code excerpt. | |
38 | '\" | |
39 | '\" .CE | |
40 | '\" End code excerpt. | |
41 | '\" | |
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. | |
48 | '\" | |
49 | '\" .VE | |
50 | '\" End of vertical sidebar. | |
51 | '\" | |
52 | '\" .DS | |
53 | '\" Begin an indented unfilled display. | |
54 | '\" | |
55 | '\" .DE | |
56 | '\" End of indented unfilled display. | |
57 | '\" | |
58 | '\" .SO | |
59 | '\" Start of list of standard options for a Tk widget. The | |
60 | '\" options follow on successive lines, in four columns separated | |
61 | '\" by tabs. | |
62 | '\" | |
63 | '\" .SE | |
64 | '\" End of list of standard options for a Tk widget. | |
65 | '\" | |
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. | |
71 | '\" | |
72 | '\" .UL arg1 arg2 | |
73 | '\" Print arg1 underlined, then print arg2 normally. | |
74 | '\" | |
75 | '\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $ | |
76 | '\" | |
77 | '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. | |
78 | .if t .wh -1.3i ^B | |
79 | .nr ^l \n(.l | |
80 | .ad b | |
81 | '\" # Start an argument description | |
82 | .de AP | |
83 | .ie !"\\$4"" .TP \\$4 | |
84 | .el \{\ | |
85 | . ie !"\\$2"" .TP \\n()Cu | |
86 | . el .TP 15 | |
87 | .\} | |
88 | .ta \\n()Au \\n()Bu | |
89 | .ie !"\\$3"" \{\ | |
90 | \&\\$1 \\fI\\$2\\fP (\\$3) | |
91 | .\".b | |
92 | .\} | |
93 | .el \{\ | |
94 | .br | |
95 | .ie !"\\$2"" \{\ | |
96 | \&\\$1 \\fI\\$2\\fP | |
97 | .\} | |
98 | .el \{\ | |
99 | \&\\fI\\$1\\fP | |
100 | .\} | |
101 | .\} | |
102 | .. | |
103 | '\" # define tabbing values for .AP | |
104 | .de AS | |
105 | .nr )A 10n | |
106 | .if !"\\$1"" .nr )A \\w'\\$1'u+3n | |
107 | .nr )B \\n()Au+15n | |
108 | .\" | |
109 | .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n | |
110 | .nr )C \\n()Bu+\\w'(in/out)'u+2n | |
111 | .. | |
112 | .AS Tcl_Interp Tcl_CreateInterp in/out | |
113 | '\" # BS - start boxed text | |
114 | '\" # ^y = starting y location | |
115 | '\" # ^b = 1 | |
116 | .de BS | |
117 | .br | |
118 | .mk ^y | |
119 | .nr ^b 1u | |
120 | .if n .nf | |
121 | .if n .ti 0 | |
122 | .if n \l'\\n(.lu\(ul' | |
123 | .if n .fi | |
124 | .. | |
125 | '\" # BE - end boxed text (draw box now) | |
126 | .de BE | |
127 | .nf | |
128 | .ti 0 | |
129 | .mk ^t | |
130 | .ie n \l'\\n(^lu\(ul' | |
131 | .el \{\ | |
132 | .\" Draw four-sided box normally, but don't draw top of | |
133 | .\" box if the box started on an earlier page. | |
134 | .ie !\\n(^b-1 \{\ | |
135 | \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' | |
136 | .\} | |
137 | .el \}\ | |
138 | \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' | |
139 | .\} | |
140 | .\} | |
141 | .fi | |
142 | .br | |
143 | .nr ^b 0 | |
144 | .. | |
145 | '\" # VS - start vertical sidebar | |
146 | '\" # ^Y = starting y location | |
147 | '\" # ^v = 1 (for troff; for nroff this doesn't matter) | |
148 | .de VS | |
149 | .if !"\\$2"" .br | |
150 | .mk ^Y | |
151 | .ie n 'mc \s12\(br\s0 | |
152 | .el .nr ^v 1u | |
153 | .. | |
154 | '\" # VE - end of vertical sidebar | |
155 | .de VE | |
156 | .ie n 'mc | |
157 | .el \{\ | |
158 | .ev 2 | |
159 | .nf | |
160 | .ti 0 | |
161 | .mk ^t | |
162 | \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' | |
163 | .sp -1 | |
164 | .fi | |
165 | .ev | |
166 | .\} | |
167 | .nr ^v 0 | |
168 | .. | |
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. | |
172 | .de ^B | |
173 | .ev 2 | |
174 | 'ti 0 | |
175 | 'nf | |
176 | .mk ^t | |
177 | .if \\n(^b \{\ | |
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 | |
182 | .\} | |
183 | .if \\n(^v \{\ | |
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 | |
186 | .\} | |
187 | .bp | |
188 | 'fi | |
189 | .ev | |
190 | .if \\n(^b \{\ | |
191 | .mk ^y | |
192 | .nr ^b 2 | |
193 | .\} | |
194 | .if \\n(^v \{\ | |
195 | .mk ^Y | |
196 | .\} | |
197 | .. | |
198 | '\" # DS - begin display | |
199 | .de DS | |
200 | .RS | |
201 | .nf | |
202 | .sp | |
203 | .. | |
204 | '\" # DE - end display | |
205 | .de DE | |
206 | .fi | |
207 | .RE | |
208 | .sp | |
209 | .. | |
210 | '\" # SO - start of list of standard options | |
211 | .de SO | |
212 | .SH "STANDARD OPTIONS" | |
213 | .LP | |
214 | .nf | |
215 | .ta 5.5c 11c | |
216 | .ft B | |
217 | .. | |
218 | '\" # SE - end of list of standard options | |
219 | .de SE | |
220 | .fi | |
221 | .ft R | |
222 | .LP | |
223 | See the \\fBoptions\\fR manual entry for details on the standard options. | |
224 | .. | |
225 | '\" # OP - start of full description for a single option | |
226 | .de OP | |
227 | .LP | |
228 | .nf | |
229 | .ta 4c | |
230 | Command-Line Name: \\fB\\$1\\fR | |
231 | Database Name: \\fB\\$2\\fR | |
232 | Database Class: \\fB\\$3\\fR | |
233 | .fi | |
234 | .IP | |
235 | .. | |
236 | '\" # CS - begin code excerpt | |
237 | .de CS | |
238 | .RS | |
239 | .nf | |
240 | .ta .25i .5i .75i 1i | |
241 | .. | |
242 | '\" # CE - end code excerpt | |
243 | .de CE | |
244 | .fi | |
245 | .RE | |
246 | .. | |
247 | .de UL | |
248 | \\$1\l'|0\(ul'\\$2 | |
249 | .. | |
250 | .TH Tk_CreatePhotoImageFormat 3 8.3 Tk "Tk Library Procedures" | |
251 | .BS | |
252 | .SH NAME | |
253 | Tk_CreatePhotoImageFormat \- define new file format for photo images | |
254 | .SH SYNOPSIS | |
255 | .nf | |
256 | \fB#include <tk.h>\fR | |
257 | .sp | |
258 | \fBTk_CreatePhotoImageFormat\fR(\fIformatPtr\fR) | |
259 | .SH ARGUMENTS | |
260 | .AS Tk_PhotoImageFormat *formatPtr | |
261 | .AP Tk_PhotoImageFormat *formatPtr in | |
262 | Structure that defines the new file format. | |
263 | .BE | |
264 | ||
265 | .SH DESCRIPTION | |
266 | .PP | |
267 | \fBTk_CreatePhotoImageFormat\fR is invoked to define a new file format | |
268 | for image data for use with photo images. The code that implements an | |
269 | image file format is called an image file format handler, or | |
270 | handler for short. The photo image code | |
271 | maintains a list of handlers that can be used to read and | |
272 | write data to or from a file. Some handlers may also | |
273 | support reading image data from a string or converting image data to a | |
274 | string format. | |
275 | The user can specify which handler to use with the \fB\-format\fR | |
276 | image configuration option or the \fB\-format\fR option to the | |
277 | \fBread\fR and \fBwrite\fR photo image subcommands. | |
278 | .PP | |
279 | An image file format handler consists of a collection of procedures | |
280 | plus a Tk_PhotoImageFormat structure, which contains the name of the | |
281 | image file format and pointers to six procedures provided by the | |
282 | handler to deal with files and strings in this format. The | |
283 | Tk_PhotoImageFormat structure contains the following fields: | |
284 | .CS | |
285 | typedef struct Tk_PhotoImageFormat { | |
286 | char *\fIname\fR; | |
287 | Tk_ImageFileMatchProc *\fIfileMatchProc\fR; | |
288 | Tk_ImageStringMatchProc *\fIstringMatchProc\fR; | |
289 | Tk_ImageFileReadProc *\fIfileReadProc\fR; | |
290 | Tk_ImageStringReadProc *\fIstringReadProc\fR; | |
291 | Tk_ImageFileWriteProc *\fIfileWriteProc\fR; | |
292 | Tk_ImageStringWriteProc *\fIstringWriteProc\fR; | |
293 | } Tk_PhotoImageFormat; | |
294 | .CE | |
295 | .PP | |
296 | The handler need not provide implementations of all six procedures. | |
297 | For example, the procedures that handle string data would not be | |
298 | provided for a format in which the image data are stored in binary, | |
299 | and could therefore contain null characters. If any procedure is not | |
300 | implemented, the corresponding pointer in the Tk_PhotoImageFormat | |
301 | structure should be set to NULL. The handler must provide the | |
302 | \fIfileMatchProc\fR procedure if it provides the \fIfileReadProc\fR | |
303 | procedure, and the \fIstringMatchProc\fR procedure if it provides the | |
304 | \fIstringReadProc\fR procedure. | |
305 | ||
306 | .SH PORTABILITY | |
307 | .PP | |
308 | In Tk 8.2 and earlier, a different interface was used. Tk 8.3 will | |
309 | still support the old format handlers if the format name is in upper | |
310 | case. If you still want to compile old format handlers with Tk8.3, | |
311 | use the flag -DUSE_OLD_IMAGE. This will restore all function prototypes | |
312 | to match the pre-8.3 situation. | |
313 | ||
314 | .SH NAME | |
315 | .PP | |
316 | \fIformatPtr->name\fR provides a name for the image type. | |
317 | Once \fBTk_CreatePhotoImageFormat\fR returns, this name may be used | |
318 | in the \fB\-format\fR photo image configuration and subcommand option. | |
319 | The manual page for the photo image (photo(n)) describes how image | |
320 | file formats are chosen based on their names and the value given to | |
321 | the \fB\-format\fR option. For new format handlers, the name should | |
322 | be in lower case. Pre-8.3 format handlers are assumed to be in | |
323 | upper case. | |
324 | ||
325 | .SH FILEMATCHPROC | |
326 | \fIformatPtr->fileMatchProc\fR provides the address of a procedure for | |
327 | Tk to call when it is searching for an image file format handler | |
328 | suitable for reading data in a given file. | |
329 | \fIformatPtr->fileMatchProc\fR must match the following prototype: | |
330 | .CS | |
331 | typedef int Tk_ImageFileMatchProc( | |
332 | Tcl_Channel \fIchan\fR, | |
333 | CONST char *\fIfileName\fR, | |
334 | Tcl_Obj *\fIformat\fR, | |
335 | int *\fIwidthPtr\fR, | |
336 | int *\fIheightPtr\fR, | |
337 | Tcl_Interp *\fIinterp\fR); | |
338 | .CE | |
339 | The \fIfileName\fR argument is the name of the file containing the | |
340 | image data, which is open for reading as \fIchan\fR. The | |
341 | \fIformat\fR argument contains the value given for the | |
342 | \fB\-format\fR option, or NULL if the option was not specified. | |
343 | If the data in the file appears to be in the format supported by this | |
344 | handler, the \fIformatPtr->fileMatchProc\fR procedure should store the | |
345 | width and height of the image in *\fIwidthPtr\fR and *\fIheightPtr\fR | |
346 | respectively, and return 1. Otherwise it should return 0. | |
347 | ||
348 | .SH STRINGMATCHPROC | |
349 | \fIformatPtr->stringMatchProc\fR provides the address of a procedure for | |
350 | Tk to call when it is searching for an image file format handler for | |
351 | suitable for reading data from a given string. | |
352 | \fIformatPtr->stringMatchProc\fR must match the following prototype: | |
353 | .CS | |
354 | typedef int Tk_ImageStringMatchProc( | |
355 | Tcl_Obj *\fIdata\fR, | |
356 | Tcl_Obj *\fIformat\fR, | |
357 | int *\fIwidthPtr\fR, | |
358 | int *\fIheightPtr\fR, | |
359 | Tcl_Interp *\fIinterp\fR); | |
360 | .CE | |
361 | The \fIdata\fR argument points to the object containing the image | |
362 | data. The \fIformat\fR argument contains the value given for | |
363 | the \fB\-format\fR option, or NULL if the option was not specified. | |
364 | If the data in the string appears to be in the format supported by | |
365 | this handler, the \fIformatPtr->stringMatchProc\fR procedure should | |
366 | store the width and height of the image in *\fIwidthPtr\fR and | |
367 | *\fIheightPtr\fR respectively, and return 1. Otherwise it should | |
368 | return 0. | |
369 | ||
370 | .SH FILEREADPROC | |
371 | \fIformatPtr->fileReadProc\fR provides the address of a procedure for | |
372 | Tk to call to read data from an image file into a photo image. | |
373 | \fIformatPtr->fileReadProc\fR must match the following prototype: | |
374 | .CS | |
375 | typedef int Tk_ImageFileReadProc( | |
376 | Tcl_Interp *\fIinterp\fR, | |
377 | Tcl_Channel \fIchan\fR, | |
378 | CONST char *\fIfileName\fR, | |
379 | Tcl_Obj *\fIformat\fR, | |
380 | PhotoHandle \fIimageHandle\fR, | |
381 | int \fIdestX\fR, int \fIdestY\fR, | |
382 | int \fIwidth\fR, int \fIheight\fR, | |
383 | int \fIsrcX\fR, int \fIsrcY\fR); | |
384 | .CE | |
385 | The \fIinterp\fR argument is the interpreter in which the command was | |
386 | invoked to read the image; it should be used for reporting errors. | |
387 | The image data is in the file named \fIfileName\fR, which is open for | |
388 | reading as \fIchan\fR. The \fIformat\fR argument contains the | |
389 | value given for the \fB\-format\fR option, or NULL if the option was | |
390 | not specified. The image data in the file, or a subimage of it, is to | |
391 | be read into the photo image identified by the handle | |
392 | \fIimageHandle\fR. The subimage of the data in the file is of | |
393 | dimensions \fIwidth\fR x \fIheight\fR and has its top-left corner at | |
394 | coordinates (\fIsrcX\fR,\fIsrcY\fR). It is to be stored in the photo | |
395 | image with its top-left corner at coordinates | |
396 | (\fIdestX\fR,\fIdestY\fR) using the \fBTk_PhotoPutBlock\fR procedure. | |
397 | The return value is a standard Tcl return value. | |
398 | ||
399 | .SH STRINGREADPROC | |
400 | \fIformatPtr->stringReadProc\fR provides the address of a procedure for | |
401 | Tk to call to read data from a string into a photo image. | |
402 | \fIformatPtr->stringReadProc\fR must match the following prototype: | |
403 | .CS | |
404 | typedef int Tk_ImageStringReadProc( | |
405 | Tcl_Interp *\fIinterp\fR, | |
406 | Tcl_Obj *\fIdata\fR, | |
407 | Tcl_Obj *\fIformat\fR, | |
408 | PhotoHandle \fIimageHandle\fR, | |
409 | int \fIdestX\fR, int \fIdestY\fR, | |
410 | int \fIwidth\fR, int \fIheight\fR, | |
411 | int \fIsrcX\fR, int \fIsrcY\fR); | |
412 | .CE | |
413 | The \fIinterp\fR argument is the interpreter in which the command was | |
414 | invoked to read the image; it should be used for reporting errors. | |
415 | The \fIdata\fR argument points to the image data in object form. | |
416 | The \fIformat\fR argument contains the | |
417 | value given for the \fB\-format\fR option, or NULL if the option was | |
418 | not specified. The image data in the string, or a subimage of it, is to | |
419 | be read into the photo image identified by the handle | |
420 | \fIimageHandle\fR. The subimage of the data in the string is of | |
421 | dimensions \fIwidth\fR x \fIheight\fR and has its top-left corner at | |
422 | coordinates (\fIsrcX\fR,\fIsrcY\fR). It is to be stored in the photo | |
423 | image with its top-left corner at coordinates | |
424 | (\fIdestX\fR,\fIdestY\fR) using the \fBTk_PhotoPutBlock\fR procedure. | |
425 | The return value is a standard Tcl return value. | |
426 | ||
427 | .SH FILEWRITEPROC | |
428 | \fIformatPtr->fileWriteProc\fR provides the address of a procedure for | |
429 | Tk to call to write data from a photo image to a file. | |
430 | \fIformatPtr->fileWriteProc\fR must match the following prototype: | |
431 | .CS | |
432 | typedef int Tk_ImageFileWriteProc( | |
433 | Tcl_Interp *\fIinterp\fR, | |
434 | CONST char *\fIfileName\fR, | |
435 | Tcl_Obj *\fIformat\fR, | |
436 | Tk_PhotoImageBlock *\fIblockPtr\fR); | |
437 | .CE | |
438 | The \fIinterp\fR argument is the interpreter in which the command was | |
439 | invoked to write the image; it should be used for reporting errors. | |
440 | The image data to be written are in memory and are described by the | |
441 | Tk_PhotoImageBlock structure pointed to by \fIblockPtr\fR; see the | |
442 | manual page FindPhoto(3) for details. The \fIfileName\fR argument | |
443 | points to the string giving the name of the file in which to write the | |
444 | image data. The \fIformat\fR argument contains the | |
445 | value given for the \fB\-format\fR option, or NULL if the option was | |
446 | not specified. The format string can contain extra characters | |
447 | after the name of the format. If appropriate, the | |
448 | \fIformatPtr->fileWriteProc\fR procedure may interpret these | |
449 | characters to specify further details about the image file. | |
450 | The return value is a standard Tcl return value. | |
451 | ||
452 | .SH STRINGWRITEPROC | |
453 | \fIformatPtr->stringWriteProc\fR provides the address of a procedure for | |
454 | Tk to call to translate image data from a photo image into a string. | |
455 | \fIformatPtr->stringWriteProc\fR must match the following prototype: | |
456 | .CS | |
457 | typedef int Tk_ImageStringWriteProc( | |
458 | Tcl_Interp *\fIinterp\fR, | |
459 | Tcl_Obj *\fIformat\fR, | |
460 | Tk_PhotoImageBlock *\fIblockPtr\fR); | |
461 | .CE | |
462 | The \fIinterp\fR argument is the interpreter in which the command was | |
463 | invoked to convert the image; it should be used for reporting errors. | |
464 | The image data to be converted are in memory and are described by the | |
465 | Tk_PhotoImageBlock structure pointed to by \fIblockPtr\fR; see the | |
466 | manual page FindPhoto(3) for details. The data for the string | |
467 | should be put in the interpreter \fIinterp\fR result. | |
468 | The \fIformat\fR argument contains the | |
469 | value given for the \fB\-format\fR option, or NULL if the option was | |
470 | not specified. The format string can contain extra characters | |
471 | after the name of the format. If appropriate, the | |
472 | \fIformatPtr->stringWriteProc\fR procedure may interpret these | |
473 | characters to specify further details about the image file. | |
474 | The return value is a standard Tcl return value. | |
475 | ||
476 | .SH "SEE ALSO" | |
477 | Tk_FindPhoto, Tk_PhotoPutBlock | |
478 | ||
479 | .SH KEYWORDS | |
480 | photo image, image file |