Android examples for Graphics:Color RGB Value
Convert RGBA color buffer to RGB color buffer
import java.nio.ByteBuffer; public class Main{ /**/*from w w w .ja v a2s .c o m*/ * Convert RGBA color buffer to RGB color buffer * * @param rgbaBuffer The RGBA buffer * @return The converted RGB buffer */ public static ByteBuffer RGBAtoRGB(final ByteBuffer rgbaBuffer) { //android.util.Log.d(TAG,"RGBAtoRGB()"); final ByteBuffer rgbBuffer = ByteBufferPool.getInstance() .getDirectByteBuffer(rgbaBuffer.capacity() * 3 / 4); rgbBuffer.position(0); rgbaBuffer.position(0); final byte[] pixelBytes = new byte[3]; while (rgbaBuffer.hasRemaining()) { ((ByteBuffer) rgbaBuffer).get(pixelBytes); rgbBuffer.put(pixelBytes); ((ByteBuffer) rgbaBuffer).get(); } ByteBufferPool.getInstance().returnDirectBuffer(rgbaBuffer); return (ByteBuffer) rgbBuffer.position(0); } }