<!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>PNG IO</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="PNG_IO"></a>PNG IO</h1><div class=CBody><p>Read and write PNG images.</p><!--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="#PNG_IO" >PNG IO</a></td><td class=SDescription>Read and write PNG images.</td></tr><tr class="SGroup"><td class=SEntry><a href="#Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#gdImageCreateFromPng" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">gdImageCreateFromPng</a></td><td class=SDescription><a href="#gdImageCreateFromPng" class=LFunction id=link2 onMouseOver="ShowTip(event, 'tt1', 'link2')" onMouseOut="HideTip('tt1')">gdImageCreateFromPng</a> is called to load images from PNG format files. </td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#gdImageCreateFromPngPtr" id=link3 onMouseOver="ShowTip(event, 'tt2', 'link3')" onMouseOut="HideTip('tt2')">gdImageCreateFromPngPtr</a></td><td class=SDescription>See <a href="#gdImageCreateFromPng" class=LFunction id=link4 onMouseOver="ShowTip(event, 'tt1', 'link4')" onMouseOut="HideTip('tt1')">gdImageCreateFromPng</a>.</td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#gdImageCreateFromPngCtx" id=link5 onMouseOver="ShowTip(event, 'tt3', 'link5')" onMouseOut="HideTip('tt3')">gdImageCreateFromPngCtx</a></td><td class=SDescription>See <a href="#gdImageCreateFromPng" class=LFunction id=link6 onMouseOver="ShowTip(event, 'tt1', 'link6')" onMouseOut="HideTip('tt1')">gdImageCreateFromPng</a>.</td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#gdImagePngEx" id=link7 onMouseOver="ShowTip(event, 'tt4', 'link7')" onMouseOut="HideTip('tt4')">gdImagePngEx</a></td><td class=SDescription><a href="#gdImagePngEx" class=LFunction id=link8 onMouseOver="ShowTip(event, 'tt4', 'link8')" onMouseOut="HideTip('tt4')">gdImagePngEx</a> outputs the specified image to the specified file in PNG format. </td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#gdImagePng" id=link9 onMouseOver="ShowTip(event, 'tt5', 'link9')" onMouseOut="HideTip('tt5')">gdImagePng</a></td><td class=SDescription>Equivalent to calling <a href="#gdImagePngEx" class=LFunction id=link10 onMouseOver="ShowTip(event, 'tt4', 'link10')" onMouseOut="HideTip('tt4')">gdImagePngEx</a> with compression of -1.</td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#gdImagePngPtr" id=link11 onMouseOver="ShowTip(event, 'tt6', 'link11')" onMouseOut="HideTip('tt6')">gdImagePngPtr</a></td><td class=SDescription>Equivalent to calling <a href="#gdImagePngPtrEx" class=LFunction id=link12 onMouseOver="ShowTip(event, 'tt7', 'link12')" onMouseOut="HideTip('tt7')">gdImagePngPtrEx</a> with compression of -1.</td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#gdImagePngPtrEx" id=link13 onMouseOver="ShowTip(event, 'tt7', 'link13')" onMouseOut="HideTip('tt7')">gdImagePngPtrEx</a></td><td class=SDescription>Identical to <a href="#gdImagePngEx" class=LFunction id=link14 onMouseOver="ShowTip(event, 'tt4', 'link14')" onMouseOut="HideTip('tt4')">gdImagePngEx</a> except that it returns a pointer to a memory area with the PNG data. </td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#gdImagePngCtx" id=link15 onMouseOver="ShowTip(event, 'tt8', 'link15')" onMouseOut="HideTip('tt8')">gdImagePngCtx</a></td><td class=SDescription>Equivalent to calling <a href="#gdImagePngCtxEx" class=LFunction id=link16 onMouseOver="ShowTip(event, 'tt9', 'link16')" onMouseOut="HideTip('tt9')">gdImagePngCtxEx</a> with compression of -1. </td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#gdImagePngCtxEx" id=link17 onMouseOver="ShowTip(event, 'tt9', 'link17')" onMouseOut="HideTip('tt9')">gdImagePngCtxEx</a></td><td class=SDescription>Outputs the given image as PNG data, but using a <a href="gd_io-h.html#gdIOCtx" class=LType id=link18 onMouseOver="ShowTip(event, 'tt10', 'link18')" onMouseOut="HideTip('tt10')">gdIOCtx</a> instead of a file. </td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="Functions"></a>Functions</h3></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gdImageCreateFromPng"></a>gdImageCreateFromPng</h3><div class=CBody><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 gdImageCreateFromPng (</td><td class="PType prettyprint " nowrap>FILE </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><p><a href="#gdImageCreateFromPng" class=LFunction id=link19 onMouseOver="ShowTip(event, 'tt1', 'link19')" onMouseOut="HideTip('tt1')">gdImageCreateFromPng</a> is called to load images from PNG format files. Invoke <a href="#gdImageCreateFromPng" class=LFunction id=link20 onMouseOver="ShowTip(event, 'tt1', 'link20')" onMouseOut="HideTip('tt1')">gdImageCreateFromPng</a> with an already opened pointer to a FILE containing the desired image. <a href="#gdImageCreateFromPng" class=LFunction id=link21 onMouseOver="ShowTip(event, 'tt1', 'link21')" onMouseOut="HideTip('tt1')">gdImageCreateFromPng</a> returns a <a href="gd-h.html#gdImagePtr" class=LType id=link22 onMouseOver="ShowTip(event, 'tt11', 'link22')" onMouseOut="HideTip('tt11')">gdImagePtr</a> to the new image, or NULL if unable to load the image (most often because the file is corrupt or does not contain a PNG image). <a href="#gdImageCreateFromPng" class=LFunction id=link23 onMouseOver="ShowTip(event, 'tt1', 'link23')" onMouseOut="HideTip('tt1')">gdImageCreateFromPng</a> does not close the file. You can inspect the sx and sy members of the image to determine its size. The image must eventually be destroyed using gdImageDestroy().</p><p>If the PNG image being loaded is a truecolor image, the resulting gdImagePtr will refer to a truecolor image. If the PNG image being loaded is a palette or grayscale image, the resulting gdImagePtr will refer to a palette image. gd retains only 8 bits of resolution for each of the red, green and blue channels, and only 7 bits of resolution for the alpha channel. The former restriction affects only a handful of very rare 48-bit color and 16-bit grayscale PNG images. The second restriction affects all semitransparent PNG images, but the difference is essentially invisible to the eye. 7 bits of alpha channel resolution is, in practice, quite a lot.</p><h4 class=CHeading>Variants</h4><p><a href="#gdImageCreateFromPngPtr" class=LFunction id=link24 onMouseOver="ShowTip(event, 'tt2', 'link24')" onMouseOut="HideTip('tt2')">gdImageCreateFromPngPtr</a> creates an image from PNG data (i.e. the contents of a PNG file) already in memory.</p><p><a href="#gdImageCreateFromPngCtx" class=LFunction id=link25 onMouseOver="ShowTip(event, 'tt3', 'link25')" onMouseOut="HideTip('tt3')">gdImageCreateFromPngCtx</a> reads in an image using the functions in a <a href="gd_io-h.html#gdIOCtx" class=LType id=link26 onMouseOver="ShowTip(event, 'tt10', 'link26')" onMouseOut="HideTip('tt10')">gdIOCtx</a> struct.</p><p><a href="gd_ss-c.html#gdImageCreateFromPngSource" class=LFunction id=link27 onMouseOver="ShowTip(event, 'tt12', 'link27')" onMouseOut="HideTip('tt12')">gdImageCreateFromPngSource</a> is similar to <a href="#gdImageCreateFromPngCtx" class=LFunction id=link28 onMouseOver="ShowTip(event, 'tt3', 'link28')" onMouseOut="HideTip('tt3')">gdImageCreateFromPngCtx</a> but uses the old <a href="gd-h.html#gdSource" class=LType >gdSource</a> interface. It is <b>obsolete</b>.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>infile</td><td class=CDLDescription>The input FILE pointer.</td></tr></table><h4 class=CHeading>Returns</h4><p>A pointer to the new image or NULL if an error occurred.</p><h4 class=CHeading>Example</h4><blockquote><pre class="prettyprint">gdImagePtr im;
... inside a function ...
FILE *in;
in = fopen("mypng.png", "rb");
im = gdImageCreateFromPng(in);
fclose(in);
// ... Use the image ...
gdImageDestroy(im);</pre></blockquote></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gdImageCreateFromPngPtr"></a>gdImageCreateFromPngPtr</h3><div class=CBody><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 gdImageCreateFromPngPtr (</td><td class="PType prettyprint " nowrap>int </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>size,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>void </td><td class="PParameterPrefix prettyprint " nowrap>*</td><td class="PParameter prettyprint " nowrap>data</td><td class="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>See <a href="#gdImageCreateFromPng" class=LFunction id=link29 onMouseOver="ShowTip(event, 'tt1', 'link29')" onMouseOut="HideTip('tt1')">gdImageCreateFromPng</a>.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gdImageCreateFromPngCtx"></a>gdImageCreateFromPngCtx</h3><div class=CBody><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 gdImageCreateFromPngCtx (</td><td class="PType prettyprint " nowrap>gdIOCtx </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><p>See <a href="#gdImageCreateFromPng" class=LFunction id=link30 onMouseOver="ShowTip(event, 'tt1', 'link30')" onMouseOut="HideTip('tt1')">gdImageCreateFromPng</a>.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gdImagePngEx"></a>gdImagePngEx</h3><div class=CBody><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 gdImagePngEx (</td><td class="PType prettyprint " nowrap>gdImagePtr </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>FILE </td><td class="PParameterPrefix prettyprint " nowrap>*</td><td class="PParameter prettyprint " nowrap>outFile,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>int </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>level</td><td class="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p><a href="#gdImagePngEx" class=LFunction id=link31 onMouseOver="ShowTip(event, 'tt4', 'link31')" onMouseOut="HideTip('tt4')">gdImagePngEx</a> outputs the specified image to the specified file in PNG format. The file must be open for writing. Under MSDOS and all versions of Windows, it is important to use “wb” as opposed to simply “w” as the mode when opening the file, and under Unix there is no penalty for doing so. <a href="#gdImagePngEx" class=LFunction id=link32 onMouseOver="ShowTip(event, 'tt4', 'link32')" onMouseOut="HideTip('tt4')">gdImagePngEx</a> does not close the file; your code must do so.</p><p>In addition, <a href="#gdImagePngEx" class=LFunction id=link33 onMouseOver="ShowTip(event, 'tt4', 'link33')" onMouseOut="HideTip('tt4')">gdImagePngEx</a> allows the level of compression to be specified. A compression level of 0 means “no compression.” A compression level of 1 means “compressed, but as quickly as possible.” A compression level of 9 means “compressed as much as possible to produce the smallest possible file.” A compression level of -1 will use the default compression level at the time zlib was compiled on your system.</p><h4 class=CHeading>Variants</h4><p><a href="#gdImagePng" class=LFunction id=link34 onMouseOver="ShowTip(event, 'tt5', 'link34')" onMouseOut="HideTip('tt5')">gdImagePng</a> is equivalent to calling <a href="#gdImagePngEx" class=LFunction id=link35 onMouseOver="ShowTip(event, 'tt4', 'link35')" onMouseOut="HideTip('tt4')">gdImagePngEx</a> with compression of -1.</p><p><a href="#gdImagePngCtx" class=LFunction id=link36 onMouseOver="ShowTip(event, 'tt8', 'link36')" onMouseOut="HideTip('tt8')">gdImagePngCtx</a> and <a href="#gdImagePngCtxEx" class=LFunction id=link37 onMouseOver="ShowTip(event, 'tt9', 'link37')" onMouseOut="HideTip('tt9')">gdImagePngCtxEx</a> write via a <a href="gd_io-h.html#gdIOCtx" class=LType id=link38 onMouseOver="ShowTip(event, 'tt10', 'link38')" onMouseOut="HideTip('tt10')">gdIOCtx</a> instead of a file handle.</p><p><a href="#gdImagePngPtr" class=LFunction id=link39 onMouseOver="ShowTip(event, 'tt6', 'link39')" onMouseOut="HideTip('tt6')">gdImagePngPtr</a> and <a href="#gdImagePngPtrEx" class=LFunction id=link40 onMouseOver="ShowTip(event, 'tt7', 'link40')" onMouseOut="HideTip('tt7')">gdImagePngPtrEx</a> store the image file to memory.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>im</td><td class=CDLDescription>the image to write</td></tr><tr><td class=CDLEntry>outFile</td><td class=CDLDescription>the output FILE* object.</td></tr><tr><td class=CDLEntry>level</td><td class=CDLDescription>compression level: 0 -> none, 1-9 -> level, -1 -> default</td></tr></table><h4 class=CHeading>Returns</h4><p>Nothing.</p><h4 class=CHeading>Example</h4><blockquote><pre class="prettyprint">gdImagePtr im;
int black, white;
FILE *out;
im = gdImageCreate(100, 100); // Create the image
white = gdImageColorAllocate(im, 255, 255, 255); // Alloc background
black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
gdImageRectangle(im, 0, 0, 99, 99, black); // Draw rectangle
out = fopen("rect.png", "wb"); // Open output file (binary)
gdImagePngEx(im, out, 9); // Write PNG, max compression
fclose(out); // Close file
gdImageDestroy(im); // Destroy image</pre></blockquote></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gdImagePng"></a>gdImagePng</h3><div class=CBody><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 </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>FILE </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><p>Equivalent to calling <a href="#gdImagePngEx" class=LFunction id=link41 onMouseOver="ShowTip(event, 'tt4', 'link41')" onMouseOut="HideTip('tt4')">gdImagePngEx</a> with compression of -1.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>im</td><td class=CDLDescription>the image to save.</td></tr><tr><td class=CDLEntry>outFile</td><td class=CDLDescription>the output FILE*.</td></tr></table><h4 class=CHeading>Returns</h4><p>Nothing.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gdImagePngPtr"></a>gdImagePngPtr</h3><div class=CBody><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 * gdImagePngPtr (</td><td class="PType prettyprint " nowrap>gdImagePtr </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>int </td><td class="PParameterPrefix prettyprint " nowrap>*</td><td class="PParameter prettyprint " nowrap>size</td><td class="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Equivalent to calling <a href="#gdImagePngPtrEx" class=LFunction id=link42 onMouseOver="ShowTip(event, 'tt7', 'link42')" onMouseOut="HideTip('tt7')">gdImagePngPtrEx</a> with compression of -1.</p><p>See <a href="#gdImagePngEx" class=LFunction id=link43 onMouseOver="ShowTip(event, 'tt4', 'link43')" onMouseOut="HideTip('tt4')">gdImagePngEx</a> for more information.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>im</td><td class=CDLDescription>the image to save.</td></tr><tr><td class=CDLEntry>size</td><td class=CDLDescription>Output: size in bytes of the result.</td></tr></table><h4 class=CHeading>Returns</h4><p>A pointer to memory containing the image data or NULL on error.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gdImagePngPtrEx"></a>gdImagePngPtrEx</h3><div class=CBody><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 * gdImagePngPtrEx (</td><td class="PType prettyprint " nowrap>gdImagePtr </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>int </td><td class="PParameterPrefix prettyprint " nowrap>*</td><td class="PParameter prettyprint " nowrap>size,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>int </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>level</td><td class="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Identical to <a href="#gdImagePngEx" class=LFunction id=link44 onMouseOver="ShowTip(event, 'tt4', 'link44')" onMouseOut="HideTip('tt4')">gdImagePngEx</a> except that it returns a pointer to a memory area with the PNG data. This memory must be freed by the caller when it is no longer needed. **The caller must invoke gdFree(), not free()**</p><p>The ‘size’ parameter receives the total size of the block of memory.</p><p>See <a href="#gdImagePngEx" class=LFunction id=link45 onMouseOver="ShowTip(event, 'tt4', 'link45')" onMouseOut="HideTip('tt4')">gdImagePngEx</a> for more information.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>im</td><td class=CDLDescription>the image to save.</td></tr><tr><td class=CDLEntry>size</td><td class=CDLDescription>Output: size in bytes of the result.</td></tr><tr><td class=CDLEntry>level</td><td class=CDLDescription>compression level: 0 -> none, 1-9 -> level, -1 -> default</td></tr></table><h4 class=CHeading>Returns</h4><p>A pointer to memory containing the image data or NULL on error.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gdImagePngCtx"></a>gdImagePngCtx</h3><div class=CBody><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 </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>gdIOCtx </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><p>Equivalent to calling <a href="#gdImagePngCtxEx" class=LFunction id=link46 onMouseOver="ShowTip(event, 'tt9', 'link46')" onMouseOut="HideTip('tt9')">gdImagePngCtxEx</a> with compression of -1. See <a href="#gdImagePngEx" class=LFunction id=link47 onMouseOver="ShowTip(event, 'tt4', 'link47')" onMouseOut="HideTip('tt4')">gdImagePngEx</a> for more information.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>im</td><td class=CDLDescription>the image to save.</td></tr><tr><td class=CDLEntry>outfile</td><td class=CDLDescription>the <a href="gd_io-h.html#gdIOCtx" class=LType id=link48 onMouseOver="ShowTip(event, 'tt10', 'link48')" onMouseOut="HideTip('tt10')">gdIOCtx</a> to write to.</td></tr></table><h4 class=CHeading>Returns</h4><p>Nothing.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gdImagePngCtxEx"></a>gdImagePngCtxEx</h3><div class=CBody><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 gdImagePngCtxEx (</td><td class="PType prettyprint " nowrap>gdImagePtr </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>gdIOCtx </td><td class="PParameterPrefix prettyprint " nowrap>*</td><td class="PParameter prettyprint " nowrap>outfile,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>int </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>level</td><td class="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Outputs the given image as PNG data, but using a <a href="gd_io-h.html#gdIOCtx" class=LType id=link49 onMouseOver="ShowTip(event, 'tt10', 'link49')" onMouseOut="HideTip('tt10')">gdIOCtx</a> instead of a file. See <gdIamgePnEx>.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>im</td><td class=CDLDescription>the image to save.</td></tr><tr><td class=CDLEntry>outfile</td><td class=CDLDescription>the <a href="gd_io-h.html#gdIOCtx" class=LType id=link50 onMouseOver="ShowTip(event, 'tt10', 'link50')" onMouseOut="HideTip('tt10')">gdIOCtx</a> to write to.</td></tr><tr><td class=CDLEntry>level</td><td class=CDLDescription>compression level: 0 -> none, 1-9 -> level, -1 -> default</td></tr></table><h4 class=CHeading>Returns</h4><p>Nothing.</p></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 id=MSelected>PNG IO</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><a href="gd_io-h.html">gd_io.h</a></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([1], 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>gdImagePtr gdImageCreateFromPng (</td><td class="PType prettyprint " nowrap>FILE </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>gdImageCreateFromPng is called to load images from PNG format files. </div></div><div class=CToolTip id="tt2"><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 gdImageCreateFromPngPtr (</td><td class="PType prettyprint " nowrap>int </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>size,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>void </td><td class="PParameterPrefix prettyprint " nowrap>*</td><td class="PParameter prettyprint " nowrap>data</td><td class="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>See gdImageCreateFromPng.</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>gdImagePtr gdImageCreateFromPngCtx (</td><td class="PType prettyprint " nowrap>gdIOCtx </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 gdImageCreateFromPng.</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>void gdImagePngEx (</td><td class="PType prettyprint " nowrap>gdImagePtr </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>FILE </td><td class="PParameterPrefix prettyprint " nowrap>*</td><td class="PParameter prettyprint " nowrap>outFile,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>int </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>level</td><td class="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>gdImagePngEx outputs the specified image to the specified file in PNG format. </div></div><div class=CToolTip id="tt5"><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 </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>FILE </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="tt6"><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 * gdImagePngPtr (</td><td class="PType prettyprint " nowrap>gdImagePtr </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>int </td><td class="PParameterPrefix prettyprint " nowrap>*</td><td class="PParameter prettyprint " nowrap>size</td><td class="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Equivalent to calling gdImagePngPtrEx with compression of -1.</div></div><div class=CToolTip id="tt7"><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 * gdImagePngPtrEx (</td><td class="PType prettyprint " nowrap>gdImagePtr </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>int </td><td class="PParameterPrefix prettyprint " nowrap>*</td><td class="PParameter prettyprint " nowrap>size,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>int </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>level</td><td class="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Identical to gdImagePngEx except that it returns a pointer to a memory area with the PNG data. </div></div><div class=CToolTip id="tt8"><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 </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>gdIOCtx </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="tt9"><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 gdImagePngCtxEx (</td><td class="PType prettyprint " nowrap>gdImagePtr </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>im,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>gdIOCtx </td><td class="PParameterPrefix prettyprint " nowrap>*</td><td class="PParameter prettyprint " nowrap>outfile,</td></tr><tr><td></td><td class="PType prettyprint " nowrap>int </td><td class="PParameterPrefix prettyprint " nowrap></td><td class="PParameter prettyprint " nowrap>level</td><td class="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Outputs the given image as PNG data, but using a gdIOCtx instead of a file. </div></div><div class=CToolTip id="tt10"><div class=CType>gdIOCtx structures hold function pointers for doing image IO.</div></div><div class=CToolTip id="tt11"><div class=CType>The data structure in which gd stores images. </div></div><div class=CToolTip id="tt12"><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 gdImageCreateFromPngSource (</td><td class="PType prettyprint " nowrap>gdSourcePtr </td><td class="PParameter prettyprint " nowrap>inSource</td><td class="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>See gdImageCreateFromPng for documentation. </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>