我正在做一个 android 应用程序来解压缩、解码和显示 HDR 图片。
这些 HDR 图片每个组件(A、R、G、B)使用 2 个字节,因此一个像素由 8 个字节的值表示,该值只能与 long 类型匹配。
我正在使用 android 的 Bitmap 来显示图片,因为它们有一个构造函数允许使用以下方法进行 HDR Bitmap.Config.RGBA_F16
:
int width = 1;
int height = 1;
Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.RGBA_F16);
不幸的是,我找不到任何方法来填充位图的像素。我使用推荐的公式,但它不能用于 Bitmap 的 setPixel(x,y,color) 方法,因为颜色必须是 int:
long color = (A & 0xffff) << 48 | (B & 0xffff) << 32 | (G & 0xffff) << 16 | (R & 0xffff);
image.setPixel(0,0,color); //Argument type error
.
我也尝试过使用 Color(它具有兼容 HDR 的方法)、Paint 和 Canvas,但没有 Bitmap 方法接受它们来设置一个像素。
谢谢你的帮助!