title: Error while converting .dcm to jpeg of type jpeg-lossless
body: <p>I am stuck in <code>1.2.840.10008.1.2.4.70 - JPEG Lossless, Non-Hierarchical, First-Order Prediction</code> while converting DCM to jpg using ImageIo.</p>
  
  <p>I have installed JAI ImageIO as instructed <a href="http://download.java.net/media/jai-imageio/builds/release/1.1/INSTALL-jai_imageio.html#Windows" rel="nofollow">here</a>, and <code>ImageIO.getReaderFormatNames()</code> is giving <code>raw jpeg tif JFIF WBMP jpeg-lossless jpeg-ls PNM JPG DICOM wbmp PNG JPEG dicom jpeg 2000 tiff BMP JPEG2000 RAW JPEG-LOSSLESS jpeg2000 GIF TIF TIFF jpg bmp pnm jfif png JPEG 2000 gif JPEG-LS</code>.</p>
  
  <p>However, I am getting Exception in thread "main": <code>java.lang.IndexOutOfBoundsException: imageIndex out of bounds</code>, while reading buffered image using reader. This is my reader code:</p>
  
  <pre><code>    ByteArrayInputStream bais = new ByteArrayInputStream(dicomData); //byte array of DICOM data
      ImageIO.scanForPlugins();
      Iterator&lt;ImageReader&gt; iter = ImageIO
                      .getImageReadersByFormatName("jpeg-lossless");
      ImageReader reader = (ImageReader) iter.next();
      ImageReadParam param = (ImageReadParam) reader.getDefaultReadParam();
      ImageInputStream iis = ImageIO.createImageInputStream(bais);
      reader.setInput(iis, false);        
      BufferedImage  buff = reader.read(0, param); // Error at this line 'imageIndex out of bounds!'
      iis.close(); 
  </code></pre>
  
  <p>Is this right way to do this or any other way?</p>