CrtPhImgFmt.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:10k
- '"
- '" Copyright (c) 1994 The Australian National University
- '" Copyright (c) 1994-1997 Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" Author: Paul Mackerras (paulus@cs.anu.edu.au),
- '" Department of Computer Science,
- '" Australian National University.
- '"
- '" RCS: @(#) $Id: CrtPhImgFmt.3,v 1.5 2001/08/23 19:11:22 hobbs Exp $
- '"
- .so man.macros
- .TH Tk_CreatePhotoImageFormat 3 8.3 Tk "Tk Library Procedures"
- .BS
- .SH NAME
- Tk_CreatePhotoImageFormat - define new file format for photo images
- .SH SYNOPSIS
- .nf
- fB#include <tk.h>fR
- .sp
- fBTk_CreatePhotoImageFormatfR(fIformatPtrfR)
- .SH ARGUMENTS
- .AS Tk_PhotoImageFormat *formatPtr
- .AP Tk_PhotoImageFormat *formatPtr in
- Structure that defines the new file format.
- .BE
- .SH DESCRIPTION
- .PP
- fBTk_CreatePhotoImageFormatfR is invoked to define a new file format
- for image data for use with photo images. The code that implements an
- image file format is called an image file format handler, or
- handler for short. The photo image code
- maintains a list of handlers that can be used to read and
- write data to or from a file. Some handlers may also
- support reading image data from a string or converting image data to a
- string format.
- The user can specify which handler to use with the fB-formatfR
- image configuration option or the fB-formatfR option to the
- fBreadfR and fBwritefR photo image subcommands.
- .PP
- An image file format handler consists of a collection of procedures
- plus a Tk_PhotoImageFormat structure, which contains the name of the
- image file format and pointers to six procedures provided by the
- handler to deal with files and strings in this format. The
- Tk_PhotoImageFormat structure contains the following fields:
- .CS
- typedef struct Tk_PhotoImageFormat {
- char *fInamefR;
- Tk_ImageFileMatchProc *fIfileMatchProcfR;
- Tk_ImageStringMatchProc *fIstringMatchProcfR;
- Tk_ImageFileReadProc *fIfileReadProcfR;
- Tk_ImageStringReadProc *fIstringReadProcfR;
- Tk_ImageFileWriteProc *fIfileWriteProcfR;
- Tk_ImageStringWriteProc *fIstringWriteProcfR;
- } Tk_PhotoImageFormat;
- .CE
- .PP
- The handler need not provide implementations of all six procedures.
- For example, the procedures that handle string data would not be
- provided for a format in which the image data are stored in binary,
- and could therefore contain null characters. If any procedure is not
- implemented, the corresponding pointer in the Tk_PhotoImageFormat
- structure should be set to NULL. The handler must provide the
- fIfileMatchProcfR procedure if it provides the fIfileReadProcfR
- procedure, and the fIstringMatchProcfR procedure if it provides the
- fIstringReadProcfR procedure.
- .SH PORTABILITY
- .PP
- In Tk 8.2 and earlier, a different interface was used. Tk 8.3 will
- still support the old format handlers if the format name is in upper
- case. If you still want to compile old format handlers with Tk8.3,
- use the flag -DUSE_OLD_IMAGE. This will restore all function prototypes
- to match the pre-8.3 situation.
- .SH NAME
- .PP
- fIformatPtr->namefR provides a name for the image type.
- Once fBTk_CreatePhotoImageFormatfR returns, this name may be used
- in the fB-formatfR photo image configuration and subcommand option.
- The manual page for the photo image (photo(n)) describes how image
- file formats are chosen based on their names and the value given to
- the fB-formatfR option. For new format handlers, the name should
- be in lower case. Pre-8.3 format handlers are assumed to be in
- upper case.
- .SH FILEMATCHPROC
- fIformatPtr->fileMatchProcfR provides the address of a procedure for
- Tk to call when it is searching for an image file format handler
- suitable for reading data in a given file.
- fIformatPtr->fileMatchProcfR must match the following prototype:
- .CS
- typedef int Tk_ImageFileMatchProc(
- Tcl_Channel fIchanfR,
- CONST char *fIfileNamefR,
- Tcl_Obj *fIformatfR,
- int *fIwidthPtrfR,
- int *fIheightPtrfR,
- Tcl_Interp *fIinterpfR);
- .CE
- The fIfileNamefR argument is the name of the file containing the
- image data, which is open for reading as fIchanfR. The
- fIformatfR argument contains the value given for the
- fB-formatfR option, or NULL if the option was not specified.
- If the data in the file appears to be in the format supported by this
- handler, the fIformatPtr->fileMatchProcfR procedure should store the
- width and height of the image in *fIwidthPtrfR and *fIheightPtrfR
- respectively, and return 1. Otherwise it should return 0.
- .SH STRINGMATCHPROC
- fIformatPtr->stringMatchProcfR provides the address of a procedure for
- Tk to call when it is searching for an image file format handler for
- suitable for reading data from a given string.
- fIformatPtr->stringMatchProcfR must match the following prototype:
- .CS
- typedef int Tk_ImageStringMatchProc(
- Tcl_Obj *fIdatafR,
- Tcl_Obj *fIformatfR,
- int *fIwidthPtrfR,
- int *fIheightPtrfR,
- Tcl_Interp *fIinterpfR);
- .CE
- The fIdatafR argument points to the object containing the image
- data. The fIformatfR argument contains the value given for
- the fB-formatfR option, or NULL if the option was not specified.
- If the data in the string appears to be in the format supported by
- this handler, the fIformatPtr->stringMatchProcfR procedure should
- store the width and height of the image in *fIwidthPtrfR and
- *fIheightPtrfR respectively, and return 1. Otherwise it should
- return 0.
- .SH FILEREADPROC
- fIformatPtr->fileReadProcfR provides the address of a procedure for
- Tk to call to read data from an image file into a photo image.
- fIformatPtr->fileReadProcfR must match the following prototype:
- .CS
- typedef int Tk_ImageFileReadProc(
- Tcl_Interp *fIinterpfR,
- Tcl_Channel fIchanfR,
- CONST char *fIfileNamefR,
- Tcl_Obj *fIformatfR,
- PhotoHandle fIimageHandlefR,
- int fIdestXfR, int fIdestYfR,
- int fIwidthfR, int fIheightfR,
- int fIsrcXfR, int fIsrcYfR);
- .CE
- The fIinterpfR argument is the interpreter in which the command was
- invoked to read the image; it should be used for reporting errors.
- The image data is in the file named fIfileNamefR, which is open for
- reading as fIchanfR. The fIformatfR argument contains the
- value given for the fB-formatfR option, or NULL if the option was
- not specified. The image data in the file, or a subimage of it, is to
- be read into the photo image identified by the handle
- fIimageHandlefR. The subimage of the data in the file is of
- dimensions fIwidthfR x fIheightfR and has its top-left corner at
- coordinates (fIsrcXfR,fIsrcYfR). It is to be stored in the photo
- image with its top-left corner at coordinates
- (fIdestXfR,fIdestYfR) using the fBTk_PhotoPutBlockfR procedure.
- The return value is a standard Tcl return value.
- .SH STRINGREADPROC
- fIformatPtr->stringReadProcfR provides the address of a procedure for
- Tk to call to read data from a string into a photo image.
- fIformatPtr->stringReadProcfR must match the following prototype:
- .CS
- typedef int Tk_ImageStringReadProc(
- Tcl_Interp *fIinterpfR,
- Tcl_Obj *fIdatafR,
- Tcl_Obj *fIformatfR,
- PhotoHandle fIimageHandlefR,
- int fIdestXfR, int fIdestYfR,
- int fIwidthfR, int fIheightfR,
- int fIsrcXfR, int fIsrcYfR);
- .CE
- The fIinterpfR argument is the interpreter in which the command was
- invoked to read the image; it should be used for reporting errors.
- The fIdatafR argument points to the image data in object form.
- The fIformatfR argument contains the
- value given for the fB-formatfR option, or NULL if the option was
- not specified. The image data in the string, or a subimage of it, is to
- be read into the photo image identified by the handle
- fIimageHandlefR. The subimage of the data in the string is of
- dimensions fIwidthfR x fIheightfR and has its top-left corner at
- coordinates (fIsrcXfR,fIsrcYfR). It is to be stored in the photo
- image with its top-left corner at coordinates
- (fIdestXfR,fIdestYfR) using the fBTk_PhotoPutBlockfR procedure.
- The return value is a standard Tcl return value.
- .SH FILEWRITEPROC
- fIformatPtr->fileWriteProcfR provides the address of a procedure for
- Tk to call to write data from a photo image to a file.
- fIformatPtr->fileWriteProcfR must match the following prototype:
- .CS
- typedef int Tk_ImageFileWriteProc(
- Tcl_Interp *fIinterpfR,
- CONST char *fIfileNamefR,
- Tcl_Obj *fIformatfR,
- Tk_PhotoImageBlock *fIblockPtrfR);
- .CE
- The fIinterpfR argument is the interpreter in which the command was
- invoked to write the image; it should be used for reporting errors.
- The image data to be written are in memory and are described by the
- Tk_PhotoImageBlock structure pointed to by fIblockPtrfR; see the
- manual page FindPhoto(3) for details. The fIfileNamefR argument
- points to the string giving the name of the file in which to write the
- image data. The fIformatfR argument contains the
- value given for the fB-formatfR option, or NULL if the option was
- not specified. The format string can contain extra characters
- after the name of the format. If appropriate, the
- fIformatPtr->fileWriteProcfR procedure may interpret these
- characters to specify further details about the image file.
- The return value is a standard Tcl return value.
- .SH STRINGWRITEPROC
- fIformatPtr->stringWriteProcfR provides the address of a procedure for
- Tk to call to translate image data from a photo image into a string.
- fIformatPtr->stringWriteProcfR must match the following prototype:
- .CS
- typedef int Tk_ImageStringWriteProc(
- Tcl_Interp *fIinterpfR,
- Tcl_Obj *fIformatfR,
- Tk_PhotoImageBlock *fIblockPtrfR);
- .CE
- The fIinterpfR argument is the interpreter in which the command was
- invoked to convert the image; it should be used for reporting errors.
- The image data to be converted are in memory and are described by the
- Tk_PhotoImageBlock structure pointed to by fIblockPtrfR; see the
- manual page FindPhoto(3) for details. The data for the string
- should be put in the interpreter fIinterpfR result.
- The fIformatfR argument contains the
- value given for the fB-formatfR option, or NULL if the option was
- not specified. The format string can contain extra characters
- after the name of the format. If appropriate, the
- fIformatPtr->stringWriteProcfR procedure may interpret these
- characters to specify further details about the image file.
- The return value is a standard Tcl return value.
- .SH "SEE ALSO"
- Tk_FindPhoto, Tk_PhotoPutBlock
- .SH KEYWORDS
- photo image, image file