LibGd 2.4.0-dev
GD Graphics library
Loading...
Searching...
No Matches
Functions
I/O Contexts

Functions

gdIOCtxPtr gdNewFileCtx (FILE *)
 Creates a new I/O context for reading/writing to a file.
 
gdIOCtxPtr gdNewDynamicCtx (int size, void *data)
 Creates a new I/O context for reading/writing to a dynamic memory buffer.
 
gdIOCtxPtr gdNewDynamicCtxEx (int size, void *data, int freeFlag)
 Creates a new I/O context for reading/writing to a dynamic memory buffer with control over memory management 2.0.21: if freeFlag is nonzero, gd will free and/or reallocate "data" as needed as described above. If freeFlag is zero, gd will never free or reallocate "data", which means that the context should only be used for reading an image from a memory buffer, or writing an image to a memory buffer which is already large enough. If the memory buffer is not large enough and an image write is attempted, the write operation will fail. Those wishing to write an image to a buffer in memory have a much simpler alternative in the gdImage[something]Ptr functions.
 
gdIOCtxPtr gdNewSSCtx (gdSourcePtr in, gdSinkPtr out)
 

Detailed Description

Function Documentation

◆ gdNewDynamicCtx()

gdIOCtxPtr gdNewDynamicCtx ( int  size,
void *  data 
)

Creates a new I/O context for reading/writing to a dynamic memory buffer.

If data is null, size is ignored and an initial data buffer is allocated automatically. This function assumes gd has the right to free or reallocate "data" at will! Also note that gd will free "data" when the IO context is freed. If data is not null, it must point to memory allocated with gdMalloc, or by a call to gdImage[something]Ptr. If not, see gdNewDynamicCtxEx for an alternative.

Parameters
sizeThe initial size of the dynamic memory buffer.
dataA pointer to a memory buffer, or NULL to allocate a new buffer.
Returns
A pointer to a new gdIOCtx structure, or NULL on failure.

◆ gdNewDynamicCtxEx()

gdIOCtxPtr gdNewDynamicCtxEx ( int  size,
void *  data,
int  freeFlag 
)

Creates a new I/O context for reading/writing to a dynamic memory buffer with control over memory management 2.0.21: if freeFlag is nonzero, gd will free and/or reallocate "data" as needed as described above. If freeFlag is zero, gd will never free or reallocate "data", which means that the context should only be used for reading an image from a memory buffer, or writing an image to a memory buffer which is already large enough. If the memory buffer is not large enough and an image write is attempted, the write operation will fail. Those wishing to write an image to a buffer in memory have a much simpler alternative in the gdImage[something]Ptr functions.

Parameters
sizeThe initial size of the dynamic memory buffer.
dataA pointer to a memory buffer, or NULL to allocate a new buffer.
freeFlagA flag indicating whether gd should manage the memory of "data". If nonzero, gd will free and/or reallocate "data" as needed. If zero, gd will not free or reallocate "data".
Returns
A pointer to a new gdIOCtx structure, or NULL on failure.

◆ gdNewFileCtx()

gdIOCtxPtr gdNewFileCtx ( FILE *  f)

Creates a new I/O context for reading/writing to a file.

returns a new I/O context for reading/writing to the specified file. The caller is responsible for closing the file when done.

Parameters
fileA pointer to a FILE object that identifies the file to be used for I/O.
Returns
A pointer to a new gdIOCtx structure, or NULL on failure.

◆ gdNewSSCtx()

gdIOCtxPtr gdNewSSCtx ( gdSourcePtr  in,
gdSinkPtr  out 
)
Deprecated:
will be removed in a future version in favor of gdNewDynamicCtxEx and retated CTX APIs