+ my_src_ptr src = (my_src_ptr) cinfo->src;
+
+ src->pub.next_input_byte = src->buffer;
+ src->pub.bytes_in_buffer = src->stream->Read(src->buffer, JPEG_IO_BUFFER_SIZE).LastRead();
+
+ if (src->pub.bytes_in_buffer == 0) // check for end-of-stream
+ {
+ // Insert a fake EOI marker
+ src->buffer[0] = 0xFF;
+ src->buffer[1] = JPEG_EOI;
+ src->pub.bytes_in_buffer = 2;
+ }