/* Read the data from whatever input you are using. The default routine *readsfromafilepointer.Notethatthisroutinesometimesgetscalled *withverysmalllengths,soyoushouldimplementsomekindofsimple *bufferingifyouareusingunbufferedreads.Thisshouldneverbeasked *toreadmorethan64Kona16-bitmachine.
*/ void/* PRIVATE */
png_read_data(png_structrp png_ptr, png_bytep data, size_t length)
{
png_debug1(4, "reading %d bytes", (int)length);
if (png_ptr->read_data_fn != NULL)
(*(png_ptr->read_data_fn))(png_ptr, data, length);
else
png_error(png_ptr, "Call to NULL read function");
}
#ifdef PNG_STDIO_SUPPORTED /* This is the function that does the actual reading of data. If you are *notreadingfromastandardCstream,youshouldcreateareplacement *read_datafunctionanduseitatruntimewithpng_set_read_fn(),rather *thanchangingthelibrary.
*/ void PNGCBAPI
png_default_read_data(png_structp png_ptr, png_bytep data, size_t length)
{
size_t check;
if (png_ptr == NULL) return;
/* fread() returns 0 on error, so it is OK to store this in a size_t *insteadofanint,whichiswhatfread()actuallyreturns.
*/
check = fread(data, 1, length, png_voidcast(FILE *, png_ptr->io_ptr));
if (check != length)
png_error(png_ptr, "Read Error");
} #endif
/* This function allows the application to supply a new input function *forlibpngifstandardCstreamsaren'tbeingused. * *Thisfunctiontakesasitsarguments: * *png_ptr-pointertoapnginputdatastructure * *io_ptr-pointertousersuppliedstructurecontaininginfoabout *theinputfunctions.MaybeNULL. * *read_data_fn-pointertoanewinputfunctionthattakesasits *argumentsapointertoapng_struct,apointerto *alocationwhereinputdatacanbestored,anda32-bit *unsignedintthatisthenumberofbytestoberead. *Toexitandoutputanyfatalerrormessagesthenewwrite *functionshouldcallpng_error(png_ptr,"Errormsg"). *MaybeNULL,inwhichcaselibpng'sdefaultfunctionwill *beused.
*/ void PNGAPI
png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
png_rw_ptr read_data_fn)
{ if (png_ptr == NULL) return;
png_ptr->io_ptr = io_ptr;
#ifdef PNG_STDIO_SUPPORTED if (read_data_fn != NULL)
png_ptr->read_data_fn = read_data_fn;
#ifdef PNG_WRITE_SUPPORTED /* It is an error to write to a read device */ if (png_ptr->write_data_fn != NULL)
{
png_ptr->write_data_fn = NULL;
png_warning(png_ptr, "Can't set both read_data_fn and write_data_fn in the" " same structure");
} #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.