This week's book giveaways are in the Refactoring and Agile forums. We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line! See this thread and this one for details.
There's a code written by an ex-colleague of mine which reads BLOBs from DB and display them as jpg in a Word document. 99% of the images work fine. However, there were two images which threw the following exception :
java.lang.IllegalArgumentException: Numbers of source Raster bands and source color space components do not match
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method)
The code is actually calling the read() method of javax.imageio.ImageIO by passing the InputStream object obtained from the Blob. The API specification of this method says:
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.