final BitmapFactory.Options options = new BitmapFactory.Options(); // Decode this file to sRGB color space. options.inPreferredColorSpace = ColorSpace.get(Named.SRGB); Bitmap bitmap = BitmapFactory.decodeFile(FILE_PATH, options);
ImageDecoder.Source source = ImageDecoder.createSource(FILE_PATH); try { bitmap = ImageDecoder.decodeBitmap(source, new ImageDecoder.OnHeaderDecodedListener() { @Override public void onHeaderDecoded(ImageDecoder decoder, ImageDecoder.ImageInfo info, ImageDecoder.Source source) { decoder.setTargetColorSpace(ColorSpace.get(Named.SRGB)); } }); } catch (IOException e) { // handle exception. }
ImageDecoder.Source source = ImageDecoder.createSource(FILE_PATH); try { bitmap = ImageDecoder.decodeBitmap(source, new ImageDecoder.OnHeaderDecodedListener() { @Override public void onHeaderDecoded(ImageDecoder decoder, ImageDecoder.ImageInfo info, ImageDecoder.Source source) { ColorSpace cs = info.getColorSpace(); // Do something... } }); } catch (IOException e) { // handle exception. }
// This is bad, don't do it! final BitmapFactory.Options options = new BitmapFactory.Options(); final Bitmap bitmap = BitmapFactory.decodeFile(FILE_PATH, options); glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES31.GL_RGBA, bitmap.getWidth(), bitmap.getHeight(), 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, bitmap, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE);
wideColorGamut
android:colorMode="wideColorGamut"
private static final int EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT = 0x3490; public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display, EGLConfig config, Object nativeWindow) { EGLSurface surface = null; try { int attribs[] = { EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT, egl.EGL_NONE }; surface = egl.eglCreateWindowSurface(display, config, nativeWindow, attribs); } catch (IllegalArgumentException e) {} return surface; }