static boolean FillInputBuffer(j_decompress_ptr cinfo) { LibJpegSourceMgr *src = (LibJpegSourceMgr *)cinfo->src; size_t nbytes = 0; nbytes = simpl_istream_read(src->istream, src->buffer, JLIB_BUFFER_SIZE); if (nbytes==0) { /* If the stream is finished, insert a fake EOI maker. */ src->buffer[0] = (JOCTET) 0xFF; src->buffer[1] = (JOCTET) JPEG_EOI; nbytes = 2; } src->pub.next_input_byte = src->buffer; src->pub.bytes_in_buffer = nbytes; return TRUE; }
/** These are callback functions to stream a PNG instead of through file. */ static void StreamReadData(png_structp png_ptr, png_bytep data, png_size_t length) { SimplInStream istrm = (SimplInStream)png_get_io_ptr(png_ptr); simpl_istream_read(istrm, data, length); }