title: Write image in java with CMYK color space
body: <p>I want to write an image in java using CMYK color space like this:</p>
  
  <pre><code>BufferedImage image= new BufferedImage(path.getBounds().width, 
  path.getBounds().height, BufferedImage.TYPE_INT_ARGB);
  Graphics2D g2d = image.createGraphics();
  color c = new Color(ColorSpaces.getDeviceCMYKColorSpace(), new float[] 
  {1.0f,1.0f,1.0f,1.0f}, 1.0f)
  g2d.setPaint(c);
  g2d.fill(path);     
  g2d.draw(path);
  g2d.dispose();
  </code></pre>
  
  <p>Then I use imageIO to write the image into JPEG, however, the resulted image, when converted to PDF, does no have the CMYK color I provided in the code, instead, it has the following </p>
  
  <p><a href="https://i.stack.imgur.com/G43wn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G43wn.png" alt="CMYK Values"></a></p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>can I use BufferedImage to write images with CMYK color space ?</li>
  <li>How do I write image using CMYK color space if the components values are 0,0,0,1.0 and alpha is 1 for example</li>
  </ol>
  
  <p>Please note that I have tried EPS and it worked fine, however, I don't feel comfortable working with EPS at this stage of my project.</p>