OK, here's what is happening.
On line 33, the
ImageIO.read method is returning
null. That results in the exception later when you try and write the image.
The Javadocs for the ImageIO.read method say:
Returns a BufferedImage as the result of decoding a supplied InputStream with an ImageReader chosen automatically from among those currently registered. The InputStream is wrapped in an ImageInputStream. If no registered ImageReader claims to be able to read the resulting stream, null is returned.
The
ImageIO class identifies a suitable
ImageReader that can read the stream - presumably based on the format of the data in the stream. There are no suitable readers registered, so the method returns null.
What I think is happening (although this is an educated guess) is that your
steg_process has messed with the bytes enough that the
ImageIO class can no longer recognise it as a JPEG. This is consistent with the way it works if you comment out the call to
steg_process.
If that's correct, how you fix it is another matter. I don't know enough about JPEG formatting to sensibly comment.
Edit: you may have noticed that long code lines mess up the width of the forum pages. I've put a line break in one of your comments to fix it.