Lib.htm 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <title>The Ghostscript library</title>
  5. <!-- $Id: Lib.htm,v 1.14.2.2 2002/02/01 05:31:25 raph Exp $ -->
  6. <!-- Originally: lib.txt -->
  7. <link rel="stylesheet" type="text/css" href="gs.css" title="Ghostscript Style">
  8. </head>
  9. <body>
  10. <!-- [1.0 begin visible header] ============================================ -->
  11. <!-- [1.1 begin headline] ================================================== -->
  12. <h1>The Ghostscript Library</h1>
  13. <!-- [1.1 end headline] ==================================================== -->
  14. <!-- [1.2 begin table of contents] ========================================= -->
  15. <h2>Table of contents</h2>
  16. <blockquote><ul>
  17. <li><a href="#GS_library">The Ghostscript library</a>
  18. <li><a href="#PS_operator_API">PostScript operator API</a>
  19. <ul>
  20. <li><a href="#Patterns">Patterns</a>
  21. <li><a href="#Lower_level_API">Lower-level API</a>
  22. </ul>
  23. <li><a href="#Full_example">A full example</a>
  24. </ul></blockquote>
  25. <!-- [1.2 end table of contents] =========================================== -->
  26. <!-- [1.3 begin hint] ====================================================== -->
  27. <p>For other information, see the <a href="Readme.htm">Ghostscript
  28. overview</a>.
  29. <!-- [1.3 end hint] ======================================================== -->
  30. <hr>
  31. <!-- [1.0 end visible header] ============================================== -->
  32. <!-- [2.0 begin contents] ================================================== -->
  33. <h2><a name="GS_library"></a>The Ghostscript library</h2>
  34. <p>
  35. This document describes the Ghostscript library, a set of procedures
  36. to implement the graphics and filtering capabilities that are primitive
  37. operations in the PostScript language and in Adobe Portable Document Format
  38. (PDF).
  39. <p>
  40. Ghostscript is actually two programs: a language interpreter, and a
  41. graphics library. The library provides, in the form of C procedures, all
  42. the graphics functions of the language, that is, approximately those
  43. facilities listed in section 8.1 of the <cite>PostScript
  44. Language Reference Manual</cite>, starting with the
  45. graphics state operators. In addition, the library provides some
  46. lower-level graphics facilities that offer higher performance in exchange
  47. for less generality.
  48. <hr>
  49. <h2><a name="PS_operator_API"></a>PostScript operator API</h2>
  50. <p>
  51. The highest level of the library, which is the one that most clients will
  52. use, directly implements the PostScript graphics operators with procedures
  53. named <b><tt>gs_XXX</tt></b>, for instance <b><tt>gs_moveto</tt></b> and
  54. <b><tt>gs_fill</tt></b>. Nearly all of these procedures take graphics
  55. state objects as their first arguments, such as
  56. <blockquote><b><tt>
  57. int gs_moveto(gs_state *, double, double);
  58. </tt></b></blockquote>
  59. <p>
  60. Nearly every procedure returns an integer code which is &gt;= 0 for a
  61. successful return or &lt;0 for a failure. The failure codes correspond
  62. directly to PostScript errors, and are defined in
  63. <b><tt>gserrors.h</tt></b>.
  64. <p>
  65. The library implements all the operators in the following sections of the
  66. <cite>PostScript Language Reference Manual</cite>, with the indicated
  67. omissions and with the APIs defined in the indicated <b><tt>.h</tt></b>
  68. files. A header of the form <b><em>A.h(B.h)</em></b> indicates that
  69. <b><em>A.h</em></b> is included in <b><em>B.h</em></b>, so
  70. <b><em>A.h</em></b> need not be included explicitly if <b><em>B.h</em></b>
  71. is included. Operators marked with * in the "omissions" column are not
  72. implemented directly; the library provides lower-level procedures that can
  73. be used to implement the operator.
  74. <p>
  75. There are slight differences in the operators that return multiple values,
  76. since C's provisions for this are awkward. Also, the control structure for
  77. the operators involving callback procedures (<b><tt>pathforall</tt></b>,
  78. <b><tt>image</tt></b>, <b><tt>colorimage</tt></b>,
  79. <b><tt>imagemask</tt></b>) is partly inverted: the client calls a procedure
  80. to set up an enumerator object, and then calls another procedure for each
  81. iteration. The <b><tt>...show</tt></b> operators,
  82. <b><tt>charpath</tt></b>, and <b><tt>stringwidth</tt></b> also use an
  83. inverted control structure.
  84. <blockquote><table cellpadding=0 cellspacing=0>
  85. <tr valign=bottom>
  86. <th align=left>Section<br>(operators)
  87. <td>&nbsp;&nbsp;
  88. <th align=left>Headers
  89. <td>&nbsp;&nbsp;
  90. <th align=left>Omissions
  91. <tr> <td colspan=5><hr>
  92. <tr valign=top> <td>Graphics state -- device-independent
  93. <td>&nbsp;
  94. <td><b><tt>gscolor.h</tt></b>(<b><tt>gsstate.h</tt></b>)<br><b><tt>gscolor1.h</tt></b><br><b><tt>gscolor2.h</tt></b><br><b><tt>gscspace.h</tt></b><br><b><tt>gshsb.h</tt></b><br><b><tt>gsline.h</tt></b>(<b><tt>gsstate.h</tt></b>)<br><b><tt>gsstate.h</tt></b>
  95. <td>&nbsp;
  96. <td>&nbsp;
  97. <tr> <td>&nbsp;
  98. <tr valign=top> <td>Graphics state -- device-dependent
  99. <td>&nbsp;
  100. <td><b><tt>gscolor.h</tt></b>(<b><tt>gsstate.h</tt></b>)<br><b><tt>gscolor1.h</tt></b><br><b><tt>gscolor2.h</tt></b><br><b><tt>gsht.h</tt></b>(<b><tt>gsht1.h</tt></b>,<b><tt>gsstate.h</tt></b>)<br><b><tt>gsht1.h</tt></b><br><b><tt>gsline.h</tt></b>(<b><tt>gsstate.h</tt></b>)
  101. <td>&nbsp;
  102. <td>&nbsp;
  103. <tr> <td>&nbsp;
  104. <tr valign=top> <td>Coordinate system and matrix
  105. <td>&nbsp;
  106. <td><b><tt>gscoord.h</tt></b><br><b><tt>gsmatrix.h</tt></b>
  107. <td>&nbsp;
  108. <td><b><tt>*matrix</tt></b>, <b><tt>*identmatrix</tt></b>, <b><tt>*concatmatrix</tt></b>, <b><tt>*invertmatrix</tt></b>
  109. <tr> <td>&nbsp;
  110. <tr valign=top> <td>Path construction
  111. <td>&nbsp;
  112. <td><b><tt>gspath.h</tt></b><br><b><tt>gspath2.h</tt></b>
  113. <td>&nbsp;
  114. <td><b><tt>*arct</tt></b>, <b><tt>*pathforall</tt></b>, <b><tt>ustrokepath</tt></b>, <b><tt>uappend</tt></b>, <b><tt>upath</tt></b>, <b><tt>ucache</tt></b>
  115. <tr> <td>&nbsp;
  116. <tr valign=top> <td>Painting
  117. <td>&nbsp;
  118. <td><b><tt>gsimage.h</tt></b><br><b><tt>gspaint.h</tt></b><br><b><tt>gspath2.h</tt></b>
  119. <td>&nbsp;
  120. <td><b><tt>*image</tt></b>, <b><tt>*colorimage</tt></b>, <b><tt>*imagemask</tt></b>, <b><tt>ufill</tt></b>, <b><tt>ueofill</tt></b>, <b><tt>ustroke</tt></b>
  121. <tr> <td>&nbsp;
  122. <tr valign=top> <td>Form and pattern
  123. <td>&nbsp;
  124. <td><b><tt>gscolor2.h</tt></b>
  125. <td>&nbsp;
  126. <td><b><tt>execform</tt></b>
  127. <tr> <td>&nbsp;
  128. <tr valign=top> <td>Device setup and output
  129. <td>&nbsp;
  130. <td><b><tt>gsdevice.h</tt></b>
  131. <td>&nbsp;
  132. <td><b><tt>*showpage</tt></b>, <b><tt>*set</tt></b>/<b><tt>currentpagedevice</tt></b>
  133. <tr> <td>&nbsp;
  134. <tr valign=top> <td>Character and font
  135. <td>&nbsp;
  136. <td><b><tt>gschar.h</tt></b><br><b><tt>gsfont.h</tt></b>
  137. <td>&nbsp;
  138. <td>*(all the <b><tt>show</tt></b> operators), <b><tt>definefont</tt></b>, <b><tt>undefinefont</tt></b>, <b><tt>findfont</tt></b>, <b><tt>*scalefont</tt></b>, <b><tt>*makefont</tt></b>, <b><tt>selectfont</tt></b>, <b><tt>[Global]FontDirectory</tt></b>, <b><tt>Standard</tt></b>/<b><tt>ISOLatin1Encoding</tt></b>, <b><tt>findencoding</tt></b>
  139. </table></blockquote>
  140. <p>
  141. The following procedures from the list above operate differently from their
  142. PostScript operator counterparts, as explained here:
  143. <dl>
  144. <dt><b><tt>gs_makepattern(gscolor2.h)</tt></b>
  145. <dd>Takes an explicit current color, rather than using the current color in
  146. the graphics state. Takes an explicit allocator for allocating the pattern
  147. implementation. See below for more details on
  148. <b><tt>gs_makepattern</tt></b>.
  149. </dl>
  150. <dl>
  151. <dt><b><tt>gs_setpattern(gscolor2.h)</tt></b>
  152. <dt><b><tt>gs_setcolor(gscolor2.h)</tt></b>
  153. <dt><b><tt>gs_currentcolor(gscolor2.h)</tt></b>
  154. <dd>Use <b><tt>gs_client_color</tt></b> rather than a set of color
  155. parameter values. See below for more details on
  156. <b><tt>gs_setpattern</tt></b>.
  157. </dl>
  158. <dl>
  159. <dt><b><tt>gs_currentdash_length/pattern/offset(gsline.h)</tt></b>
  160. <dd>Splits up <b><tt>currentdash</tt></b> into three separate procedures.
  161. </dl>
  162. <dl>
  163. <dt><b><tt>gs_screen_init/currentpoint/next/install(gsht.h)</tt></b>
  164. <dd>Provide an "enumeration style" interface to <b><tt>setscreen</tt></b>.
  165. (<b><tt>gs_setscreen</tt></b> is also implemented.)
  166. </dl>
  167. <dl>
  168. <dt><b><tt>gs_rotate/scale/translate(gscoord.h)</tt></b>
  169. <dt><b><tt>gs_[i][d]transform(gscoord.h)</tt></b>
  170. <dd>These always operate on the graphics state CTM. The corresponding
  171. operations on free-standing matrices are in <b><tt>gsmatrix.h</tt></b> and
  172. have different names.
  173. </dl>
  174. <dl>
  175. <dt><b><tt>gs_path_enum_alloc/init/next/cleanup(gspath.h)</tt></b>
  176. <dd>Provide an "enumeration style" implementation of
  177. <b><tt>pathforall</tt></b>.
  178. </dl>
  179. <dl>
  180. <dt><b><tt>gs_image_enum_alloc(gsimage.h)</tt></b>
  181. <dt><b><tt>gs_image_init/next/cleanup(gsimage.h)</tt></b>
  182. <dd>Provide an "enumeration style" interface to the equivalent of
  183. <b><tt>image</tt></b>, <b><tt>imagemask</tt></b>, and
  184. <b><tt>colorimage</tt></b>. In the <b><tt>gs_image_t</tt></b>,
  185. <b><tt>ColorSpace</tt></b> provides an explicit color space, rather than
  186. using the current color space in the graphics state;
  187. <b><tt>ImageMask</tt></b> distinguishes <b><tt>imagemask</tt></b> from
  188. <b><tt>[color]image</tt></b>.
  189. </dl>
  190. <dl>
  191. <dt><b><tt>gs_get/putdeviceparams(gsdevice.h)</tt></b>
  192. <dd>Take a <b><tt>gs_param_list</tt></b> for specifying or receiving the
  193. parameter values. See <b><tt>gsparam.h</tt></b> for more details.
  194. </dl>
  195. <dl>
  196. <dt><b><tt>gs_show_enum_alloc/release(gschar.h)</tt></b>
  197. <dt><b><tt>gs_xxxshow_[n_]init(gschar.h)</tt></b>
  198. <dt><b><tt>gs_show_next(gschar.h)</tt></b>
  199. <dd>Provide an "enumeration style" interface to writing text. Note that
  200. control returns to the caller if the character must be rasterized.
  201. </dl>
  202. <p>
  203. This level of the library also implements the following operators from other
  204. sections of the Manual:
  205. <blockquote><table cellpadding=0 cellspacing=0>
  206. <tr valign=bottom>
  207. <th align=left>Section<br>(operators)
  208. <td>&nbsp;&nbsp;
  209. <th align=left>Headers
  210. <td>&nbsp;&nbsp;
  211. <th align=left>Operators
  212. <tr> <td colspan=5><hr>
  213. <tr valign=top> <td>Interpreter parameter
  214. <td>&nbsp;
  215. <td><b><tt>gsfont.h</tt></b>
  216. <td>&nbsp;
  217. <td><b><tt>cachestatus</tt></b>, <b><tt>setcachelimit</tt></b>, <b><tt>*set/currentcacheparams</tt></b>
  218. <tr valign=top> <td>Display PostScript
  219. <td>&nbsp;
  220. <td><b><tt>gsstate.h</tt></b>
  221. <td>&nbsp;
  222. <td><b><tt>set/currenthalftonephase</tt></b>
  223. </table></blockquote>
  224. <p>
  225. In order to obtain the full PostScript Level 2 functionality listed above,
  226. <b><tt>FEATURE_DEVS</tt></b> must be set in the makefile to include at least the following:
  227. <blockquote><b><tt>
  228. FEATURE_DEVS=patcore.dev cmykcore.dev psl2core.dev dps2core.dev ciecore.dev path1core.dev hsbcore.dev
  229. </tt></b></blockquote>
  230. <p>
  231. The <b><tt>*lib.mak</tt></b> makefiles mentioned below do not always
  232. include all of these features.
  233. <p>
  234. Files named <b><tt>gs*.c</tt></b> implement the higher level of the
  235. graphics library. As might be expected, all procedures, variables, and
  236. structures available at this level begin with "<b><tt>gs_</tt></b>".
  237. Structures that appear in these interfaces, but whose definitions may be
  238. hidden from clients, also have names beginning with "<b><tt>gs_</tt></b>",
  239. that is, the prefix, not the implementation, reflects at what level the
  240. abstraction is made available.
  241. <h3><a name="Patterns"></a>Patterns</h3>
  242. <p>
  243. Patterns are the most complicated PostScript language objects that the
  244. library API deals with. As in PostScript, defining a pattern color and
  245. using the color are two separate operations.
  246. <p>
  247. <b><tt>gs_makepattern</tt></b> defines a pattern color. Its arguments are as follows:
  248. <blockquote><table cellpadding=0 cellspacing=0>
  249. <tr valign=top> <td><b><tt>gs_client_color *</tt></b>
  250. <td>&nbsp;&nbsp;&nbsp;
  251. <td>The resulting <b><tt>Pattern</tt></b> color is stored here. This is different from PostScript, which has no color objects <em>per se</em>, and hence returns a modified copy of the dictionary.
  252. <tr valign=top> <td><b><tt>const gs_client_pattern *</tt></b>
  253. <td>&nbsp;
  254. <td>The analogue of the original <b><tt>Pattern</tt></b> dictionary, described in detail just below.
  255. <tr valign=top> <td><b><tt>const gs_matrix *</tt></b>
  256. <td>&nbsp;
  257. <td>Corresponds to the matrix argument of the <b><tt>makepattern</tt></b> operator.
  258. <tr valign=top> <td><b><tt>gs_state *</tt></b>
  259. <td>&nbsp;
  260. <td>The current graphics state.
  261. <tr valign=top> <td><b><tt>gs_memory_t *</tt></b>
  262. <td>&nbsp;
  263. <td>The allocator to use for allocating the saved data for the
  264. <b><tt>Pattern</tt></b> color. If this is
  265. <b><tt>NULL</tt></b>, <b><tt>gs_makepattern</tt></b> uses the
  266. same allocator that allocated the graphics state. Library
  267. clients should probably always use <b><tt>NULL</tt></b>.
  268. </table></blockquote>
  269. <p>
  270. The <b><tt>gs_client_pattern</tt></b> structure defined in
  271. <b><tt>gscolor2.h</tt></b> corresponds to the <b><tt>Pattern</tt></b>
  272. dictionary that is the argument to the PostScript language
  273. <b><tt>makepattern</tt></b> operator. This structure has one extra member,
  274. <b><tt>void&nbsp;*client_data</tt></b>, which is a place for clients to
  275. store a pointer to additional data for the <b><tt>PaintProc</tt></b>; this
  276. provides the same functionality as putting additional keys in the
  277. <b><tt>Pattern</tt></b> dictionary at the PostScript language level. The
  278. <b><tt>PaintProc</tt></b> is an ordinary C procedure that takes as
  279. parameters a <b><tt>gs_client_color&nbsp;*</tt></b>, which is the
  280. <b><tt>Pattern</tt></b> color that is being used for painting, and a
  281. <b><tt>gs_state&nbsp;*</tt></b>, which is the same graphics state that
  282. would be presented to the <b><tt>PaintProc</tt></b> in PostScript.
  283. Currently the <b><tt>gs_client_color&nbsp;*</tt></b> is always the current
  284. color in the graphics state, but the <b><tt>PaintProc</tt></b> should not
  285. rely on this. The <b><tt>PaintProc</tt></b> can retrieve the
  286. <b><tt>gs_client_pattern&nbsp;*</tt></b> from the
  287. <b><tt>gs_client_color&nbsp;*</tt></b> with the
  288. <b><tt>gs_getpattern</tt></b> procedure, also defined in
  289. <b><tt>gscolor2.h</tt></b>, and from there, it can retrieve the
  290. <b><tt>client_data</tt></b> pointer.
  291. <p>
  292. The normal way to set a <b><tt>Pattern</tt></b> color is to call
  293. <b><tt>gs_setpattern</tt></b> with the graphics state and with the
  294. <b><tt>gs_client_color</tt></b> returned by <b><tt>gs_makepattern</tt></b>.
  295. After that, one can use <b><tt>gs_setcolor</tt></b> to set further
  296. <b><tt>Pattern</tt></b> colors (colored, or uncolored with the same
  297. underlying color space); the rules are the same as those in PostScript.
  298. Note that for <b><tt>gs_setpattern</tt></b>, the
  299. <b><tt>paint.values</tt></b> in the <b><tt>gs_client_color</tt></b> must be
  300. filled in for uncolored patterns; this corresponds to the additional
  301. arguments for the PostScript <b><tt>setpattern</tt></b> operator in the
  302. uncolored case.
  303. <p>
  304. There is a special procedure <b><tt>gs_makebitmappattern</tt></b> for creating bitmap-based
  305. patterns. Its API is documented in <b><tt>gscolor2.h</tt></b>; its implementation, in
  306. <b><tt>gspcolor.c</tt></b>, may be useful as an example of a pattern using a particularly
  307. simple <b><tt>PaintProc.</tt></b>
  308. <h3><a name="Lower_level_API"></a>Lower-level API</h3>
  309. <p>
  310. Files named <b><tt>gx*.c</tt></b> implement the lower level of the graphics
  311. library. The interfaces at the <b><tt>gx</tt></b> level are less stable,
  312. and expose more of the implementation detail, than those at the
  313. <b><tt>gs</tt></b> level: in particular, the <b><tt>gx</tt></b> interfaces
  314. generally use device coordinates in an internal fixed-point representation,
  315. as opposed to the <b><tt>gs</tt></b> interfaces that use floating point
  316. user coordinates. Named entities at this level begin with
  317. <b><tt>gx_</tt></b>.
  318. <p>
  319. Files named <b><tt>gz*.c</tt></b> and <b><tt>gz*.h</tt></b> are internal to
  320. the Ghostscript implementation, and are not designed to be called by
  321. clients.
  322. <hr>
  323. <h2><a name="Full_example"></a>A full example</h2>
  324. <p>
  325. The file <b><tt>gslib.c</tt></b> in the Ghostscript fileset is a complete
  326. example program that initializes the library and produces output using it;
  327. files named <b><tt>*lib.mak</tt></b> (such as <b><tt>ugcclib.mak</tt></b>
  328. and <b><tt>bclib.mak</tt></b>) are makefiles using <b><tt>gslib.c</tt></b>
  329. as the main program. The following annotated excerpts from this file are
  330. intended to provide a roadmap for applications that call the library.
  331. <blockquote><pre>/* Capture stdin/out/err before gs.h redefines them. */
  332. #include &lt;stdio.h&gt;
  333. static FILE *real_stdin, *real_stdout, *real_stderr;
  334. static void
  335. get_real(void)
  336. { real_stdin = stdin, real_stdout = stdout, real_stderr = stderr;
  337. }</pre></blockquote>
  338. <p>
  339. Any application using Ghostscript should include the fragment above at the
  340. very beginning of the main program.
  341. <blockquote><pre>#include "gx.h"</pre></blockquote>
  342. <p>
  343. The <b><tt>gx.h</tt></b> header includes a wealth of declarations related
  344. to the Ghostscript memory manager, portability machinery, debugging
  345. framework, and other substrate facilities. Any application file that calls
  346. any Ghostscript API functions should probably include <b><tt>gx.h</tt></b>.
  347. <blockquote><pre>/* Configuration information imported from gconfig.c. */
  348. extern gx_device *gx_device_list[];
  349. /* Other imported procedures */
  350. /* from gsinit.c */
  351. extern void gs_lib_init(P1(FILE *));
  352. extern void gs_lib_finit(P2(int, int));
  353. /* from gsalloc.c */
  354. extern gs_ref_memory_t *ialloc_alloc_state(P2(gs_memory_t *, uint));</pre></blockquote>
  355. <p>
  356. The externs above are needed for initializing the library.
  357. <blockquote><pre> gs_ref_memory_t *imem;
  358. #define mem ((gs_memory_t *)imem)
  359. gs_state *pgs;
  360. gx_device *dev = gx_device_list[0];
  361. gp_init();
  362. get_real();
  363. gs_stdin = real_stdin;
  364. gs_stdout = real_stdout;
  365. gs_stderr = real_stderr;
  366. gs_lib_init(stdout);
  367. ....
  368. imem = ialloc_alloc_state(&amp;gs_memory_default, 20000);
  369. imem-&gt;space = 0;
  370. ....
  371. pgs = gs_state_alloc(mem);</pre></blockquote>
  372. <p>
  373. The code above initializes the library and its memory manager. <b><tt>pgs</tt></b> now
  374. points to the graphics state that will be passed to the drawing routines in
  375. the library.
  376. <blockquote><pre> gs_setdevice_no_erase(pgs, dev); /* can't erase yet */
  377. { gs_point dpi;
  378. gs_screen_halftone ht;
  379. gs_dtransform(pgs, 72.0, 72.0, &amp;dpi);
  380. ht.frequency = min(fabs(dpi.x), fabs(dpi.y)) / 16.001;
  381. ht.angle = 0;
  382. ht.spot_function = odsf;
  383. gs_setscreen(pgs, &amp;ht);
  384. }</pre></blockquote>
  385. <p>
  386. The code above initializes the default device and sets a default halftone
  387. screen. (For brevity, we have omitted the definition of odsf, the spot
  388. function.)
  389. <blockquote><pre> /* gsave and grestore (among other places) assume that */
  390. /* there are at least 2 gstates on the graphics stack. */
  391. /* Ensure that now. */
  392. gs_gsave(pgs);</pre></blockquote>
  393. <p>
  394. The call above completes initializing the graphics state. When the program
  395. is finished, it should execute:
  396. <blockquote><pre> gs_lib_finit(0, 0);</pre></blockquote>
  397. <!-- [2.0 end contents] ==================================================== -->
  398. <!-- [3.0 begin visible trailer] =========================================== -->
  399. <hr>
  400. <p>
  401. <small>Copyright &copy; 1996, 1997, 1998 Aladdin Enterprises.
  402. All rights reserved.</small>
  403. <p>
  404. <small>This file is part of AFPL Ghostscript. See the
  405. <a href="Public.htm">Aladdin Free Public License</a> (the "License") for
  406. full details of the terms of using, copying, modifying, and redistributing
  407. AFPL Ghostscript.</small>
  408. <p>
  409. <small>Ghostscript version 7.04, 31 January 2002
  410. <!-- [3.0 end visible trailer] ============================================= -->
  411. </body>
  412. </html>