title: How to convert an indexed image to a RGB image in Java?
body: <p>I have a color indexed TIFF image (8-bits) and I want to convert it to a RGB 24-bits image (not indexed). What would be the way to do that?</p>
  
  <p>I'm using JMagick. In a weird way, it works fine for indexed 8-bits images that are grayscale when i use:</p>
  
  <pre><code>image.transformRgbImage(info.getColorspace());
  </code></pre>
  
  <p>even if the image, though not indexed any more, is still 8-bits after that, which is lucky as it is grayscale and should actually be 8-bits. The weird stuff is that the transformRgbImage() performs that although I'd rather expect it to convert the image to a 24-bits one. Anyway...</p>
  
  <p>The same way doesn't work for a color indexed 8-bits image. I just don't know how to use the JMagick API to achieve that goal. I tried setting:</p>
  
  <pre><code>image.setDepth(24);
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>info.setDepth(24);
  </code></pre>
  
  <p>but both result in an EXCEPTION_ACCESS_VIOLATION. When I set:</p>
  
  <pre><code>info.setDepth(32);
  </code></pre>
  
  <p>no exception is raised, 1) but the image is 32-bits, which shouldn't be, and 2) it is all black (1 unique color). Why does the setDepth(24) raises such an exception?? How should I do?</p>
  
  <p>Thanks in advance for your help.</p>