Blob Blame History Raw
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>/parent/libgd/docs/naturaldocs/tmp/gd_io.h</title><link rel="stylesheet" type="text/css" href="../styles/main.css"><script language=JavaScript src="../javascript/main.js"></script><script language=JavaScript src="../javascript/prettify.js"></script><script language=JavaScript src="../javascript/searchdata.js"></script></head><body class="ContentPage" onLoad="NDOnLoad();prettyPrint();"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>

<!--  Generated by Natural Docs, version 1.52 -->
<!--  http://www.naturaldocs.org  -->

<!-- saved from url=(0026)http://www.naturaldocs.org -->




<div id=Content><div class="CFile"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="gd_io.h"></a>gd_io.h</h1><div class=CBody><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#gd_io.h" >gd_io.h</a></td><td class=SDescription></td></tr><tr class="SGroup"><td class=SEntry><a href="#Types" >Types</a></td><td class=SDescription></td></tr><tr class="SType SIndent1 SMarked"><td class=SEntry><a href="#gdIOCtx" >gdIOCtx</a></td><td class=SDescription>gdIOCtx structures hold function pointers for doing image IO.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="Types"></a>Types</h3></div></div>

<div class="CType"><div class=CTopic><h3 class=CTitle><a name="gdIOCtx"></a>gdIOCtx</h3><div class=CBody><p>gdIOCtx structures hold function pointers for doing image IO.</p><p>Most of the gd functions that read and write files, such as <a href="gd_png-c.html#gdImagePng" class=LFunction id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">gdImagePng</a> also have variants that accept a <a href="#gdIOCtx" class=LType id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">gdIOCtx</a> structure; see <a href="gd_png-c.html#gdImagePngCtx" class=LFunction id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">gdImagePngCtx</a> and <a href="gd_jpeg-c.html#gdImageCreateFromJpegCtx" class=LFunction id=link4 onMouseOver="ShowTip(event, 'tt4', 'link4')" onMouseOut="HideTip('tt4')">gdImageCreateFromJpegCtx</a>.</p><p>Those who wish to provide their own custom routines to read and write images can populate a gdIOCtx structure with functions of their own devising to to read and write data.&nbsp; For image reading, the only mandatory functions are getC and getBuf, which must return the number of characters actually read, or a negative value on error or EOF.&nbsp; These functions must read the number of characters requested unless at the end of the file.</p><p>For image writing, the only mandatory functions are putC and putBuf, which return the number of characters written; these functions must write the number of characters requested except in the event of an error.&nbsp; The seek and tell functions are only required in conjunction with the gd2 file format, which supports quick loading of partial images.&nbsp; The gd_free function will not be invoked when calling the standard Ctx functions; it is an implementation convenience when adding new data types to gd.&nbsp; For examples, see gd_png.c, gd_gd2.c, gd_jpeg.c, etc., all of which rely on gdIOCtx to implement the standard image read and write functions.</p><blockquote><pre>typedef struct gdIOCtx
{
  int (*getC) (struct gdIOCtx *);
  int (*getBuf) (struct gdIOCtx *, void *, int wanted);

  void (*putC) (struct gdIOCtx *, int);
  int (*putBuf) (struct gdIOCtx *, const void *, int wanted);

  // seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
  int (*seek) (struct gdIOCtx *, const int);
  long (*tell) (struct gdIOCtx *);

  void (*gd_free) (struct gdIOCtx *);
} gdIOCtx;</pre></blockquote></div></div></div>

</div><!--Content-->


<div id=Footer><a href="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->


<div id=Menu><div class=MEntry><div class=MFile><a href="preamble-txt.html">About LibGD 2.<wbr>3.0-dev</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent1')">Image Formats</a><div class=MGroupContent id=MGroupContent1><div class=MEntry><div class=MFile><a href="gd_bmp-c.html">BMP IO</a></div></div><div class=MEntry><div class=MFile><a href="gd_gd-c.html">GD IO</a></div></div><div class=MEntry><div class=MFile><a href="gd_gd2-c.html">GD2 IO</a></div></div><div class=MEntry><div class=MFile><a href="gd_gif_in-c.html">GIF Input</a></div></div><div class=MEntry><div class=MFile><a href="gd_gif_out-c.html">GIF Output</a></div></div><div class=MEntry><div class=MFile><a href="gd_jpeg-c.html">JPEG IO</a></div></div><div class=MEntry><div class=MFile><a href="gd_png-c.html">PNG IO</a></div></div><div class=MEntry><div class=MFile><a href="gd_tga-c.html">TGA Input</a></div></div><div class=MEntry><div class=MFile><a href="gd_tiff-c.html">TIFF IO</a></div></div><div class=MEntry><div class=MFile><a href="gd_wbmp-c.html">WBMP IO</a></div></div><div class=MEntry><div class=MFile><a href="gd_webp-c.html">WebP IO</a></div></div><div class=MEntry><div class=MFile><a href="gd_xbm-c.html">XBM IO</a></div></div><div class=MEntry><div class=MFile><a href="gdxpm-c.html">XPM Input</a></div></div></div></div></div><div class=MEntry><div class=MFile><a href="gd_topal-c.html">Color Quantization</a></div></div><div class=MEntry><div class=MFile><a href="gd_crop-c.html">Cropping</a></div></div><div class=MEntry><div class=MFile><a href="gdft-c.html">FreeType font rendering</a></div></div><div class=MEntry><div class=MFile><a href="gd-c.html">gd.c</a></div></div><div class=MEntry><div class=MFile><a href="gd-h.html">gd.h</a></div></div><div class=MEntry><div class=MFile><a href="gd_filename-c.html">gd_filename.c</a></div></div><div class=MEntry><div class=MFile><a href="gd_interpolation-c.html">gd_interpolation.c</a></div></div><div class=MEntry><div class=MFile id=MSelected>gd_io.h</div></div><div class=MEntry><div class=MFile><a href="gd_io_dp-c.html">gd_io_dp.c</a></div></div><div class=MEntry><div class=MFile><a href="gd_ss-c.html">gd_ss.c</a></div></div><div class=MEntry><div class=MFile><a href="gd_version-c.html">gd_version.c</a></div></div><div class=MEntry><div class=MFile><a href="gd_color_map-c.html">gdColorMapLookup</a></div></div><div class=MEntry><div class=MFile><a href="gdhelpers-c.html">gdFree</a></div></div><div class=MEntry><div class=MFile><a href="gdfx-c.html">gdfx.c</a></div></div><div class=MEntry><div class=MFile><a href="gd_color_match-c.html">gdImageColorMatch</a></div></div><div class=MEntry><div class=MFile><a href="gd_nnquant-c.html">gdImageNeuQuant</a></div></div><div class=MEntry><div class=MFile><a href="gd_io_file-c.html">gdNewFileCtx</a></div></div><div class=MEntry><div class=MFile><a href="gd_io_ss-c.html">gdNewSSCtx</a></div></div><div class=MEntry><div class=MFile><a href="gd_filter-c.html">Image Filters</a></div></div><div class=MEntry><div class=MFile><a href="license-txt.html">License</a></div></div><div class=MEntry><div class=MFile><a href="gd_matrix-c.html">Matrix</a></div></div><div class=MEntry><div class=MFile><a href="gd_transform-c.html">Transformations</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent2')">Built-in Fonts</a><div class=MGroupContent id=MGroupContent2><div class=MEntry><div class=MFile><a href="gdfontg-c.html">Giant Font</a></div></div><div class=MEntry><div class=MFile><a href="gdfontl-c.html">Large Font</a></div></div><div class=MEntry><div class=MFile><a href="gdfontmb-c.html">Medium Bold Font</a></div></div><div class=MEntry><div class=MFile><a href="gdfonts-c.html">Small Font</a></div></div><div class=MEntry><div class=MFile><a href="gdfontt-c.html">Tiny Font</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent3')">Index</a><div class=MGroupContent id=MGroupContent3><div class=MEntry><div class=MIndex><a href="../index/Constants.html">Constants</a></div></div><div class=MEntry><div class=MIndex><a href="../index/General.html">Everything</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Files.html">Files</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Functions.html">Functions</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Macros.html">Macros</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Types.html">Types</a></div></div></div></div></div><script type="text/javascript"><!--
var searchPanel = new SearchPanel("searchPanel", "HTML", "../search");
--></script><div id=MSearchPanel class=MSearchPanelInactive><input type=text id=MSearchField value=Search onFocus="searchPanel.OnSearchFieldFocus(true)" onBlur="searchPanel.OnSearchFieldFocus(false)" onKeyUp="searchPanel.OnSearchFieldChange()"><select id=MSearchType onFocus="searchPanel.OnSearchTypeFocus(true)" onBlur="searchPanel.OnSearchTypeFocus(false)" onChange="searchPanel.OnSearchTypeChange()"><option  id=MSearchEverything selected value="General">Everything</option><option value="Constants">Constants</option><option value="Files">Files</option><option value="Functions">Functions</option><option value="Macros">Macros</option><option value="Types">Types</option></select></div><script language=JavaScript><!--
HideAllBut([], 4);// --></script></div><!--Menu-->



<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>void gdImagePng (</td><td class="PType  prettyprint " nowrap>gdImagePtr&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap></td><td class="PParameter  prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>FILE&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap>*</td><td class="PParameter  prettyprint " nowrap>outFile</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Equivalent to calling gdImagePngEx with compression of -1.</div></div><div class=CToolTip id="tt2"><div class=CType>gdIOCtx structures hold function pointers for doing image IO.</div></div><div class=CToolTip id="tt3"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>void gdImagePngCtx (</td><td class="PType  prettyprint " nowrap>gdImagePtr&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap></td><td class="PParameter  prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>gdIOCtx&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap>*</td><td class="PParameter  prettyprint " nowrap>outfile</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Equivalent to calling gdImagePngCtxEx with compression of -1. </div></div><div class=CToolTip id="tt4"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>gdImagePtr gdImageCreateFromJpegCtx(</td><td class="PType  prettyprint " nowrap>gdIOCtx&nbsp;</td><td class="PParameterPrefix  prettyprint " nowrap>*</td><td class="PParameter  prettyprint " nowrap>infile</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>See gdImageCreateFromJpeg.</div></div><!--END_ND_TOOLTIPS-->




<div id=MSearchResultsWindow><iframe src="" frameborder=0 name=MSearchResults id=MSearchResults></iframe><a href="javascript:searchPanel.CloseResultsWindow()" id=MSearchResultsWindowClose>Close</a></div>


<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>