title: BufferedImage TYPE_BYTE_BINARY change color of pixel
body: <p>I have been struggling to find and answer to this issue. I am trying to change the color of a pixel in a large BufferedImage with the imageType of TYPE_BYTE_BINARY. By default when I create the image it will create a black image which is fine but I cannot seem to be able to change pixel color to white.</p>
  
  <p>This is the basic idea of what I want to do.</p>
  
  <pre><code>BufferedImage bi = new BufferedImage(dim[0], dim[1], BufferedImage.TYPE_BYTE_BINARY);
  bi.setRBG(x, y, 255)
  </code></pre>
  
  <p>This seems weird to me as a TYPE_BYTE_BINARY image will not have RGB color, so I know that that is not the correct solution.</p>
  
  <p>Another idea that I had was to create multiple bufferedImage TYPE_BYTE_BINARY with the createGraphics() method and then combine all of those buffered images into one large bufferedImage but I could not find any information about that when using the TYPE_BYTE_BINARY imageType.</p>
  
  <p>When reading up on this I came across people saying that you need to use createGraphics() method on the BufferedImage but I don't want to do that as it will use up too much memory.</p>
  
  <p>I came across this link <a href="http://docs.oracle.com/javase/7/docs/api/java/awt/image/Raster.html" rel="nofollow">http://docs.oracle.com/javase/7/docs/api/java/awt/image/Raster.html</a> specifically for this method createPackedRaster()(the second one). This seems like it might be on the right track.</p>
  
  <p>Are those the only options to be able to edit a TYPE_BYTE_BINARY image? Or is there another way that is similar to the way that python handles 1 bit depth images?</p>
  
  <p>In python this is all that needs to be done.</p>
  
  <pre><code>im = Image.new("1", (imageDim, imageDim), "white")
  picture = im.load()
  picture[x, y] = 0 # 0 or 1 to change color black or white
  </code></pre>
  
  <p>All help or guidance is appreciated.</p>