title: How can I set pixels in Java BufferedImages using non-ARGB color spaces?
body: <p>I'm writing an application that needs to work with 16-bit &quot;5-5-5&quot; RGB colors (that is, 5 bits for each color and one bit of padding).  In order to handle these images, I am using the <a href="https://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferedImage.html" rel="nofollow noreferrer">BufferedImage</a> class provided by AWT.  The BufferedImage class specifically allows for the usage of non-RGB color spaces by taking either a ColorModel object or a predefined image type constant - one of which is the 5-5-5 pixel format that I need.</p>
  <p>My problem is this: the BufferedImage &quot;setRGB()&quot; method states in its description that color values provided are &quot;assumed to be in the default RGB color model, TYPE_INT_ARGB, and default sRGB color space&quot; (per the BufferedImage documentation page).  No other method seems to accept values designed for different color spaces, either.</p>
  <p><strong>Is there a way to use my non-standard color space directly with BufferedImage, or would I have to rely on the class's internal color conversion mechanisms to handle all of my colors?</strong> (Or am I just misreading/misunderstanding something about how the class works?)</p>