"Fossies" - the Fresh Open Source Software Archive

Member "libgd-2.3.2/docs/naturaldocs/html/files/gd_io-h.html" (5 Mar 2021, 12652 Bytes) of package /linux/www/libgd-2.3.2.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the project site itself.

gd_io.h

Summary
gd_io.h
Types
gdIOCtxgdIOCtx structures hold function pointers for doing image IO.

Types

gdIOCtx

gdIOCtx structures hold function pointers for doing image IO.

Most of the gd functions that read and write files, such as gdImagePng also have variants that accept a gdIOCtx structure; see gdImagePngCtx and gdImageCreateFromJpegCtx.

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.  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.  These functions must read the number of characters requested unless at the end of the file.

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.  The seek and tell functions are only required in conjunction with the gd2 file format, which supports quick loading of partial images.  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.  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.

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;
void gdImagePng (gdImagePtr im,
FILE *outFile)
Equivalent to calling gdImagePngEx with compression of -1.
gdIOCtx structures hold function pointers for doing image IO.
void gdImagePngCtx (gdImagePtr im,
gdIOCtx *outfile)
Equivalent to calling gdImagePngCtxEx with compression of -1.
gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile)
See gdImageCreateFromJpeg.
Close