CrtPhImgFmt.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:10k
源码类别:

通讯编程

开发平台:

Visual C++

  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. .so man.macros
  15. .TH Tk_CreatePhotoImageFormat 3 8.3 Tk "Tk Library Procedures"
  16. .BS
  17. .SH NAME
  18. Tk_CreatePhotoImageFormat - define new file format for photo images
  19. .SH SYNOPSIS
  20. .nf
  21. fB#include <tk.h>fR
  22. .sp
  23. fBTk_CreatePhotoImageFormatfR(fIformatPtrfR)
  24. .SH ARGUMENTS
  25. .AS Tk_PhotoImageFormat *formatPtr
  26. .AP Tk_PhotoImageFormat *formatPtr in
  27. Structure that defines the new file format.
  28. .BE
  29. .SH DESCRIPTION
  30. .PP
  31. fBTk_CreatePhotoImageFormatfR is invoked to define a new file format
  32. for image data for use with photo images.  The code that implements an
  33. image file format is called an image file format handler, or
  34. handler for short.  The photo image code
  35. maintains a list of handlers that can be used to read and
  36. write data to or from a file.  Some handlers may also
  37. support reading image data from a string or converting image data to a
  38. string format.
  39. The user can specify which handler to use with the fB-formatfR
  40. image configuration option or the fB-formatfR option to the
  41. fBreadfR and fBwritefR photo image subcommands.
  42. .PP
  43. An image file format handler consists of a collection of procedures
  44. plus a Tk_PhotoImageFormat structure, which contains the name of the
  45. image file format and pointers to six procedures provided by the
  46. handler to deal with files and strings in this format.  The
  47. Tk_PhotoImageFormat structure contains the following fields:
  48. .CS
  49. typedef struct Tk_PhotoImageFormat {
  50. char *fInamefR;
  51. Tk_ImageFileMatchProc *fIfileMatchProcfR;
  52. Tk_ImageStringMatchProc *fIstringMatchProcfR;
  53. Tk_ImageFileReadProc *fIfileReadProcfR;
  54. Tk_ImageStringReadProc *fIstringReadProcfR;
  55. Tk_ImageFileWriteProc *fIfileWriteProcfR;
  56. Tk_ImageStringWriteProc *fIstringWriteProcfR;
  57. } Tk_PhotoImageFormat;
  58. .CE
  59. .PP
  60. The handler need not provide implementations of all six procedures.
  61. For example, the procedures that handle string data would not be
  62. provided for a format in which the image data are stored in binary,
  63. and could therefore contain null characters.  If any procedure is not
  64. implemented, the corresponding pointer in the Tk_PhotoImageFormat
  65. structure should be set to NULL.  The handler must provide the
  66. fIfileMatchProcfR procedure if it provides the fIfileReadProcfR
  67. procedure, and the fIstringMatchProcfR procedure if it provides the
  68. fIstringReadProcfR procedure.
  69. .SH PORTABILITY
  70. .PP
  71. In Tk 8.2 and earlier, a different interface was used. Tk 8.3 will
  72. still support the old format handlers if the format name is in upper
  73. case. If you still want to compile old format handlers with Tk8.3,
  74. use the flag -DUSE_OLD_IMAGE. This will restore all function prototypes
  75. to match the pre-8.3 situation.
  76. .SH NAME
  77. .PP
  78. fIformatPtr->namefR provides a name for the image type.
  79. Once fBTk_CreatePhotoImageFormatfR returns, this name may be used
  80. in the fB-formatfR photo image configuration and subcommand option.
  81. The manual page for the photo image (photo(n)) describes how image
  82. file formats are chosen based on their names and the value given to
  83. the fB-formatfR option. For new format handlers, the name should
  84. be in lower case. Pre-8.3 format handlers are assumed to be in
  85. upper case.
  86. .SH FILEMATCHPROC
  87. fIformatPtr->fileMatchProcfR provides the address of a procedure for
  88. Tk to call when it is searching for an image file format handler
  89. suitable for reading data in a given file.
  90. fIformatPtr->fileMatchProcfR must match the following prototype:
  91. .CS
  92. typedef int Tk_ImageFileMatchProc(
  93. Tcl_Channel fIchanfR,
  94. CONST char *fIfileNamefR,
  95. Tcl_Obj *fIformatfR,
  96. int *fIwidthPtrfR,
  97. int *fIheightPtrfR,
  98. Tcl_Interp *fIinterpfR);
  99. .CE
  100. The fIfileNamefR argument is the name of the file containing the
  101. image data, which is open for reading as fIchanfR.  The
  102. fIformatfR argument contains the value given for the
  103. fB-formatfR option, or NULL if the option was not specified.
  104. If the data in the file appears to be in the format supported by this
  105. handler, the fIformatPtr->fileMatchProcfR procedure should store the
  106. width and height of the image in *fIwidthPtrfR and *fIheightPtrfR
  107. respectively, and return 1.  Otherwise it should return 0.
  108. .SH STRINGMATCHPROC
  109. fIformatPtr->stringMatchProcfR provides the address of a procedure for
  110. Tk to call when it is searching for an image file format handler for
  111. suitable for reading data from a given string.
  112. fIformatPtr->stringMatchProcfR must match the following prototype:
  113. .CS
  114. typedef int Tk_ImageStringMatchProc(
  115. Tcl_Obj *fIdatafR,
  116. Tcl_Obj *fIformatfR,
  117. int *fIwidthPtrfR,
  118. int *fIheightPtrfR,
  119. Tcl_Interp *fIinterpfR);
  120. .CE
  121. The fIdatafR argument points to the object containing the image
  122. data.  The fIformatfR argument contains the value given for
  123. the fB-formatfR option, or NULL if the option was not specified.
  124. If the data in the string appears to be in the format supported by
  125. this handler, the fIformatPtr->stringMatchProcfR procedure should
  126. store the width and height of the image in *fIwidthPtrfR and
  127. *fIheightPtrfR respectively, and return 1.  Otherwise it should
  128. return 0.
  129. .SH FILEREADPROC
  130. fIformatPtr->fileReadProcfR provides the address of a procedure for
  131. Tk to call to read data from an image file into a photo image.
  132. fIformatPtr->fileReadProcfR must match the following prototype:
  133. .CS
  134. typedef int Tk_ImageFileReadProc(
  135. Tcl_Interp *fIinterpfR,
  136. Tcl_Channel fIchanfR,
  137. CONST char *fIfileNamefR,
  138. Tcl_Obj *fIformatfR,
  139. PhotoHandle fIimageHandlefR,
  140. int fIdestXfR, int fIdestYfR,
  141. int fIwidthfR, int fIheightfR,
  142. int fIsrcXfR, int fIsrcYfR);
  143. .CE
  144. The fIinterpfR argument is the interpreter in which the command was
  145. invoked to read the image; it should be used for reporting errors.
  146. The image data is in the file named fIfileNamefR, which is open for
  147. reading as fIchanfR.  The fIformatfR argument contains the
  148. value given for the fB-formatfR option, or NULL if the option was
  149. not specified.  The image data in the file, or a subimage of it, is to
  150. be read into the photo image identified by the handle
  151. fIimageHandlefR.  The subimage of the data in the file is of
  152. dimensions fIwidthfR x fIheightfR and has its top-left corner at
  153. coordinates (fIsrcXfR,fIsrcYfR).  It is to be stored in the photo
  154. image with its top-left corner at coordinates
  155. (fIdestXfR,fIdestYfR) using the fBTk_PhotoPutBlockfR procedure.
  156. The return value is a standard Tcl return value.
  157. .SH STRINGREADPROC
  158. fIformatPtr->stringReadProcfR provides the address of a procedure for
  159. Tk to call to read data from a string into a photo image.
  160. fIformatPtr->stringReadProcfR must match the following prototype:
  161. .CS
  162. typedef int Tk_ImageStringReadProc(
  163. Tcl_Interp *fIinterpfR,
  164. Tcl_Obj *fIdatafR,
  165. Tcl_Obj *fIformatfR,
  166. PhotoHandle fIimageHandlefR,
  167. int fIdestXfR, int fIdestYfR,
  168. int fIwidthfR, int fIheightfR,
  169. int fIsrcXfR, int fIsrcYfR);
  170. .CE
  171. The fIinterpfR argument is the interpreter in which the command was
  172. invoked to read the image; it should be used for reporting errors.
  173. The fIdatafR argument points to the image data in object form.
  174. The fIformatfR argument contains the
  175. value given for the fB-formatfR option, or NULL if the option was
  176. not specified.  The image data in the string, or a subimage of it, is to
  177. be read into the photo image identified by the handle
  178. fIimageHandlefR.  The subimage of the data in the string is of
  179. dimensions fIwidthfR x fIheightfR and has its top-left corner at
  180. coordinates (fIsrcXfR,fIsrcYfR).  It is to be stored in the photo
  181. image with its top-left corner at coordinates
  182. (fIdestXfR,fIdestYfR) using the fBTk_PhotoPutBlockfR procedure.
  183. The return value is a standard Tcl return value.
  184. .SH FILEWRITEPROC
  185. fIformatPtr->fileWriteProcfR provides the address of a procedure for
  186. Tk to call to write data from a photo image to a file.
  187. fIformatPtr->fileWriteProcfR must match the following prototype:
  188. .CS
  189. typedef int Tk_ImageFileWriteProc(
  190. Tcl_Interp *fIinterpfR,
  191. CONST char *fIfileNamefR,
  192. Tcl_Obj *fIformatfR,
  193. Tk_PhotoImageBlock *fIblockPtrfR);
  194. .CE
  195. The fIinterpfR argument is the interpreter in which the command was
  196. invoked to write the image; it should be used for reporting errors.
  197. The image data to be written are in memory and are described by the
  198. Tk_PhotoImageBlock structure pointed to by fIblockPtrfR; see the
  199. manual page FindPhoto(3) for details.  The fIfileNamefR argument
  200. points to the string giving the name of the file in which to write the
  201. image data.  The fIformatfR argument contains the
  202. value given for the fB-formatfR option, or NULL if the option was
  203. not specified.  The format string can contain extra characters
  204. after the name of the format.  If appropriate, the
  205. fIformatPtr->fileWriteProcfR procedure may interpret these
  206. characters to specify further details about the image file.
  207. The return value is a standard Tcl return value.
  208. .SH STRINGWRITEPROC
  209. fIformatPtr->stringWriteProcfR provides the address of a procedure for
  210. Tk to call to translate image data from a photo image into a string.
  211. fIformatPtr->stringWriteProcfR must match the following prototype:
  212. .CS
  213. typedef int Tk_ImageStringWriteProc(
  214. Tcl_Interp *fIinterpfR,
  215. Tcl_Obj *fIformatfR,
  216. Tk_PhotoImageBlock *fIblockPtrfR);
  217. .CE
  218. The fIinterpfR argument is the interpreter in which the command was
  219. invoked to convert the image; it should be used for reporting errors.
  220. The image data to be converted are in memory and are described by the
  221. Tk_PhotoImageBlock structure pointed to by fIblockPtrfR; see the
  222. manual page FindPhoto(3) for details.  The data for the string
  223. should be put in the interpreter fIinterpfR result.
  224. The fIformatfR argument contains the
  225. value given for the fB-formatfR option, or NULL if the option was
  226. not specified.  The format string can contain extra characters
  227. after the name of the format.  If appropriate, the
  228. fIformatPtr->stringWriteProcfR procedure may interpret these
  229. characters to specify further details about the image file.
  230. The return value is a standard Tcl return value.
  231. .SH "SEE ALSO"
  232. Tk_FindPhoto, Tk_PhotoPutBlock
  233. .SH KEYWORDS
  234. photo image, image file