title: Renderscript conversion from ARGB8888 to RGB565
body: <p>I'm receiving Bitmaps in ARGB8888 format, but I need to process it through some algorithm that only accepts RGB565. I want to convert this bitmap to the new format using Renderscript but it seems the allocation in and allocation out should be of equal (or compatible).
  bitmapIn is of type ARGB_8888 and bitmapOut is of type RGB_565</p>
  
  <blockquote>
    <p>Caused by: android.renderscript.RSIllegalArgumentException: Allocation kind is PIXEL_RGBA,  type UNSIGNED_8 of 4 bytes, passed bitmap was RGB_565</p>
  </blockquote>
  
  <p>Java:
  </p>
  
  <pre><code>public void convert(final Bitmap bitmapIn, Bitmap bitmapOut)
  {
      mInAllocation = Allocation.createFromBitmap(mRS, bitmapIn, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
      Type.Builder tb = new Type.Builder(mRS, Element.RGB_565(mRS)).setX(bitmapIn.getWidth()).setY(bitmapOut.getWidth());
      mOutAllocation = Allocation.createTyped(mRS, tb.create());
      // Call custom method (not forEach_root) so we can have uchar4 in and uchar3 out
      mScript.forEach_convert(mInAllocation, mOutAllocation);
      mOutAllocation.copyTo(bitmapOut);
  }
  </code></pre>
  
  <p>Renderscript:
  </p>
  
  <pre><code>// Convert to RGB565 by quantizing the individual channels
  void convert(const uchar4* v_in, uchar3* v_out)
  {
      v_out-&gt;x = v_in-&gt;x &gt;&gt; 3;
      v_out-&gt;y = v_in-&gt;y &gt;&gt; 2;
      v_out-&gt;z = v_in-&gt;z &gt;&gt; 3;
  }
  </code></pre>
  
  <p>Note that if I make both bitmaps ARGB_8888 and have convert() working on both uchar4* (and just copy the alpha (w) channel, then I see the bitmap being altered.</p>
  
  <p>I know that 565 equals 16 bits, so in reality its more likely a uchar2, but it also is incompatible with the allocation in type.</p>
  
  <p>How can one do this type conversions in Renderscript?</p>