title: Imebra - Change color contrasts
body: <p>I am able to load dicom image using imebra, and want to change the colors of image, but cant figure out a way. I want to achieve functionality as in Dicomite app. </p>
  
  <p>Following is my code: </p>
  
  <pre><code>public void loadDCM() {
  
    com.imebra.DataSet loadedDataSet = com.imebra.CodecFactory.load(dicomPath.getPath());
  
    com.imebra.VOIs voi = loadedDataSet.getVOIs();
  
    com.imebra.Image image = loadedDataSet.getImageApplyModalityTransform(0);
    //        com.imebra.Image image = loadedDataSet.getImage(0);
    String colorSpace = image.getColorSpace();
  
  
    long width = image.getWidth();
    long height = image.getHeight();
  
    TransformsChain transformsChain = new TransformsChain();
    com.imebra.DrawBitmap drawBitmap = new com.imebra.DrawBitmap(transformsChain);
  
  
    com.imebra.TransformsChain chain = new com.imebra.TransformsChain();
    if (com.imebra.ColorTransformsFactory.isMonochrome(image.getColorSpace())) {
     // Allocate a VOILUT transform. If the DataSet does not contain any pre-defined
     //  settings then we will find the optimal ones.
     VOILUT voilutTransform = new VOILUT();
  
     // Retrieve the VOIs (center/width pairs)
     com.imebra.VOIs vois = loadedDataSet.getVOIs();
  
     // Retrieve the LUTs
     List &lt; LUT &gt; luts = new ArrayList &lt; LUT &gt; ();
     for (long scanLUTs = 0;; scanLUTs++) {
      try {
       luts.add(loadedDataSet.getLUT(new com.imebra.TagId(0x0028, 0x3010), scanLUTs));
      } catch (Exception e) {
       break;
      }
     }
  
     if (!vois.isEmpty()) {
      voilutTransform.setCenterWidth(vois.get(0).getCenter(), vois.get(0).getWidth());
     } else if (!luts.isEmpty()) {
      voilutTransform.setLUT(luts.get(0));
     } else {
      voilutTransform.applyOptimalVOI(image, 0, 0, width, height);
     }
  
     chain.addTransform(voilutTransform);
  
     com.imebra.DrawBitmap draw = new com.imebra.DrawBitmap(chain);
  
     // Ask for the size of the buffer (in bytes)
  
     long requestedBufferSize = draw.getBitmap(image, drawBitmapType_t.drawBitmapRGBA, 4, new byte[0]);
  
     byte buffer[] = new byte[(int) requestedBufferSize]; // Ideally you want to reuse this in subsequent calls to getBitmap()
     ByteBuffer byteBuffer = ByteBuffer.wrap(buffer);
  
     // Now fill the buffer with the image data and create a bitmap from it
     drawBitmap.getBitmap(image, drawBitmapType_t.drawBitmapRGBA, 4, buffer);
     Bitmap renderBitmap = Bitmap.createBitmap((int) image.getWidth(), (int) image.getHeight(), Bitmap.Config.ARGB_8888);
     renderBitmap.copyPixelsFromBuffer(byteBuffer);
  
     image_view.setImageBitmap(renderBitmap);
  
    }
  </code></pre>