|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
<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>
|
|
Packit |
ed3af9 |
if (browserType) {document.write("");if (browserVer) {document.write(" "); }}// --></script>
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
PNG IORead and write PNG images.
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
gdImageCreateFromPnggdImagePtr gdImageCreateFromPng ( | FILE | * | inFile | ) |
|
gdImageCreateFromPng is called to load images from PNG format files. Invoke gdImageCreateFromPng with an already opened pointer to a FILE containing the desired image. gdImageCreateFromPng returns a gdImagePtr 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). gdImageCreateFromPng 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(). 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. VariantsgdImageCreateFromPngPtr creates an image from PNG data (i.e. the contents of a PNG file) already in memory. gdImageCreateFromPngCtx reads in an image using the functions in a gdIOCtx struct. gdImageCreateFromPngSource is similar to gdImageCreateFromPngCtx but uses the old gdSource interface. It is obsolete. Parametersinfile | The input FILE pointer. |
ReturnsA pointer to the new image or NULL if an error occurred. ExamplegdImagePtr im;
|
|
Packit |
ed3af9 |
... inside a function ...
|
|
Packit |
ed3af9 |
FILE *in;
|
|
Packit |
ed3af9 |
in = fopen("mypng.png", "rb");
|
|
Packit |
ed3af9 |
im = gdImageCreateFromPng(in);
|
|
Packit |
ed3af9 |
fclose(in);
|
|
Packit |
ed3af9 |
// ... Use the image ...
|
|
Packit |
ed3af9 |
gdImageDestroy(im);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
gdImageCreateFromPngPtrgdImagePtr gdImageCreateFromPngPtr ( | int | | size, | | void | * | data | ) |
|
See gdImageCreateFromPng.
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
gdImageCreateFromPngCtxgdImagePtr gdImageCreateFromPngCtx ( | gdIOCtx | * | infile | ) |
|
See gdImageCreateFromPng.
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
gdImagePngExvoid gdImagePngEx ( | gdImagePtr | | im, | | FILE | * | outFile, | | int | | level | ) |
|
gdImagePngEx 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. gdImagePngEx does not close the file; your code must do so. In addition, gdImagePngEx 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. VariantsgdImagePng is equivalent to calling gdImagePngEx with compression of -1. gdImagePngCtx and gdImagePngCtxEx write via a gdIOCtx instead of a file handle. gdImagePngPtr and gdImagePngPtrEx store the image file to memory. Parametersim | the image to write | outFile | the output FILE* object. | level | compression level: 0 -> none, 1-9 -> level, -1 -> default |
ReturnsNothing. ExamplegdImagePtr im;
|
|
Packit |
ed3af9 |
int black, white;
|
|
Packit |
ed3af9 |
FILE *out;
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
im = gdImageCreate(100, 100); // Create the image
|
|
Packit |
ed3af9 |
white = gdImageColorAllocate(im, 255, 255, 255); // Alloc background
|
|
Packit |
ed3af9 |
black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
|
|
Packit |
ed3af9 |
gdImageRectangle(im, 0, 0, 99, 99, black); // Draw rectangle
|
|
Packit |
ed3af9 |
out = fopen("rect.png", "wb"); // Open output file (binary)
|
|
Packit |
ed3af9 |
gdImagePngEx(im, out, 9); // Write PNG, max compression
|
|
Packit |
ed3af9 |
fclose(out); // Close file
|
|
Packit |
ed3af9 |
gdImageDestroy(im); // Destroy image
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
gdImagePngvoid gdImagePng ( | gdImagePtr | | im, | | FILE | * | outFile | ) |
|
Equivalent to calling gdImagePngEx with compression of -1. Parametersim | the image to save. | outFile | the output FILE*. |
ReturnsNothing.
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
gdImagePngPtrvoid * gdImagePngPtr ( | gdImagePtr | | im, | | int | * | size | ) |
|
Equivalent to calling gdImagePngPtrEx with compression of -1. See gdImagePngEx for more information. Parametersim | the image to save. | size | Output: size in bytes of the result. |
ReturnsA pointer to memory containing the image data or NULL on error.
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
gdImagePngPtrExvoid * gdImagePngPtrEx ( | gdImagePtr | | im, | | int | * | size, | | int | | level | ) |
|
Identical to gdImagePngEx 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()** The ‘size’ parameter receives the total size of the block of memory. See gdImagePngEx for more information. Parametersim | the image to save. | size | Output: size in bytes of the result. | level | compression level: 0 -> none, 1-9 -> level, -1 -> default |
ReturnsA pointer to memory containing the image data or NULL on error.
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
gdImagePngCtxvoid gdImagePngCtx ( | gdImagePtr | | im, | | gdIOCtx | * | outfile | ) |
|
Equivalent to calling gdImagePngCtxEx with compression of -1. See gdImagePngEx for more information. Parametersim | the image to save. | outfile | the gdIOCtx to write to. |
ReturnsNothing.
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
gdImagePngCtxExvoid gdImagePngCtxEx ( | gdImagePtr | | im, | | gdIOCtx | * | outfile, | | int | | level | ) |
|
Outputs the given image as PNG data, but using a gdIOCtx instead of a file. See <gdIamgePnEx>. Parametersim | the image to save. | outfile | the gdIOCtx to write to. | level | compression level: 0 -> none, 1-9 -> level, -1 -> default |
ReturnsNothing.
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
var searchPanel = new SearchPanel("searchPanel", "HTML", "../search");
|
|
Packit |
ed3af9 |
--></script><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> <script language=JavaScript>
|
|
Packit |
ed3af9 |
HideAllBut([1], 4);// --></script>
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
<iframe src="" frameborder=0 name=MSearchResults id=MSearchResults></iframe> Close
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
<script language=JavaScript>
|
|
Packit |
ed3af9 |
if (browserType) {if (browserVer) {document.write(""); }document.write("");}// --></script></body></html>
|