pdfimages: support listing/extracting inline images

The difficulty with extracting inline images is that inline images do
not provide any way of determining the length or end of image data
without decoding the image. We can get the length by using ImageStream
to decode the data then check the stream position. But then we are
still unable to extract the undecoded image data because embedded
streams can only be read once.

Since inline images tend to be small the solution implemented is to
modify EmbedStream to keep a copy of the data read from it in memory
and then allow the data to be read again.

Two new functions have been added to EmbedStream. rewind() will cause
EmbedStream.getChar() to stop recording data and switch to replaying
the saved data, returning EOF when the end of the saved data is
reached. The restore() function will make getChar() switch back to
reading from the parent stream.

ImageOutputDev can now extract or get the image size by first using
ImageStream to read data from the embedded stream. After calling
rewind() the undecoded image data can be read from the embedded stream
until EOF is returned. Then restore() is called so that Gfx can read
the 'EI' from the end of the embedded stream.

Bug 25625
5 files changed