ImageFileFormat::canUnderstand advances stream

Hi there,
the subject sounds trivial, but I was a little bit puzzled to realise this.
Actually I was doing this:

PNGImageFormat jPNGReader;

jassert(jPNGReader.canUnderstand(jDataStream))
Image jPic = jPNGReader.decodeImage(jDataStream);

The decoding failed because canUnderstand advanced the strem. I didn’t expect this. Would it be convenient to have a bool parameter to tell canUnderstand() to rewind the stream to where it was before the check? Or are the ImageFileFormat classes not be meant to be used this way?

If each format had to rewind the stream, they’d all end up containing the same duplicated code, and in many cases the caller won’t actually need the stream to be rewound. That’s why I did it this way.

And in the code you wrote, there’s actually no point in calling the method at all - you could just call decodeImage and assert if it fails.

OK, I get the point.
Thanks.