title: Java save CMYK image to file
body: <p>I'm trying to create image in CMYK Colorspace and after working with it, for example, painting lines etc., save it to file. Unfortunately, there isn't a lot of information in the internet about CMYK in java. I have found only an article <a href="http://carback.us/rick/blog/?p=58" rel="nofollow">http://carback.us/rick/blog/?p=58</a>. But there the Image is being saved to Pdf, using iText library. But I need it to be savet to png or jpeg file. Here is the code:</p>
  
  <pre><code>public BufferedImage createCMYKBufferedImage(double l_width, double l_height) {
      ColorSpace colorSpace = SimpleCMYKColorSpace.getInstance();
      ComponentColorModel l_ccm = new ComponentColorModel(colorSpace, false, false,
                              1, DataBuffer.TYPE_FLOAT);
      int[] l_bandoff = {0, 1, 2, 3}; //Index for each color (C, is index 0, etc)
      PixelInterleavedSampleModel l_sm = new PixelInterleavedSampleModel(
                                 DataBuffer.TYPE_FLOAT,
                                 (int)l_width, (int)l_height,
                                     4,(int)l_width*4, l_bandoff);
      WritableRaster l_raster = WritableRaster.createWritableRaster(l_sm,
              new Point(0, 0));
      return new BufferedImage(l_ccm, l_raster, false, null);
  }
  </code></pre>
  
  <p>When I'm trying to save an image, i'm just calling </p>
  
  <blockquote>
    <p>ImageIO.write(image, format, file);</p>
  </blockquote>
  
  <p>Can anybody help me?</p>