Exemple #1
0
  private static Buffer getPixels(final Bitmap pBitmap, final PixelFormat pPixelFormat) {
    final int[] pixelsARGB_8888 = GLHelper.getPixelsARGB_8888(pBitmap);

    switch (pPixelFormat) {
      case RGB_565:
        return ByteBuffer.wrap(GLHelper.convertARGB_8888toRGB_565(pixelsARGB_8888));
      case RGBA_8888:
        return IntBuffer.wrap(GLHelper.convertARGB_8888toRGBA_8888(pixelsARGB_8888));
      case RGBA_4444:
        return ByteBuffer.wrap(GLHelper.convertARGB_8888toARGB_4444(pixelsARGB_8888));
      case A_8:
        return ByteBuffer.wrap(GLHelper.convertARGB_8888toA_8(pixelsARGB_8888));
      default:
        throw new IllegalArgumentException(
            "Unexpected " + PixelFormat.class.getSimpleName() + ": '" + pPixelFormat + "'.");
    }
  }