使用查找表 (LUT) 进行色彩校正
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 设备之间的 HDR 功能各不相同,这可能会导致 HDR 显示输出不一致。查找表 (LUT) 是一种旨在解决此不一致性的全新色彩校正解决方案。此不一致性通过规定颜色校正方式(而不是委托给未定义的设备专属颜色校正机制)来解决。
SDK 前提条件
如需实现 LUT,您的 SDK 版本必须为 36 或更高版本。
实现 LUT
如需将 LUT 应用于 SurfaceControl
,请按以下步骤操作:
- 创建
DisplayLuts
实例。
- 使用 LUT 数据缓冲区、LUT 维度和 LUT 的采样键创建
DisplayLuts.Entry
实例。如需了解详情,请参阅 LutProperties
文档。
- 调用
DisplayLuts#set(DisplayLuts.Entry luts)
或 DisplayLuts#set(DisplayLuts.Entry first, DisplayLuts.Entry second)
来设置 LUT 条目。该框架支持 1D LUT、3D LUT 或 1D 和 3D LUT 的组合。
- 调用
SurfaceControl.Transaction#setLuts
以将 LUT 应用于图层。
Kotlin
val sc = SurfaceControl.Builder().build()
val luts = DisplayLuts()
val entry = DisplayLuts.Entry(
floatArrayOf(0.5f, 0.5f, 0.5f, 0.5f),
LutProperties.ONE_DIMENSION,
LutProperties.SAMPLING_KEY_MAX_RGB
)
luts.set(entry)
SurfaceControl.Transaction().setLuts(sc, luts).apply()
Java
SurfaceControl sc = new SurfaceControl.Builder().build();
DisplayLuts luts = new DisplayLuts();
DisplayLuts.Entry entry = new DisplayLuts.Entry(
new float[]{0.5f, 0.5f, 0.5f, 0.5f},
LutProperties.ONE_DIMENSION,
LutProperties.SAMPLING_KEY_MAX_RGB
);
luts.set(entry);
new SurfaceControl.Transaction().setLuts(sc, luts).apply();
您还可以使用 OverlayProperties.getLutProperties()
了解设备的 LUT 属性,并确定硬件混合渲染器是否可以处理所选的 LUT。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-21。
[null,null,["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# Color correct with look-up tables (LUTs)\n\nVarying HDR capabilities across Android devices can lead to fragmented HDR\ndisplay outputs. A look-up table (LUT) is a new color correction solution\ndesigned to resolve this inconsistency. This inconsistency is resolved by\n*prescribing* a way to color correct, rather than delegating to an undefined\nper-device color correction mechanism.\n\nSDK prerequisites\n-----------------\n\nTo implement LUTs, your SDK version must 36 or higher.\n\nImplement a LUT\n---------------\n\nFollow these steps to apply a LUT to a [`SurfaceControl`](/reference/android/view/SurfaceControl):\n\n1. Create a [`DisplayLuts`](/reference/android/hardware/DisplayLuts) instance.\n2. Create [`DisplayLuts.Entry`](/reference/android/hardware/DisplayLuts.Entry) instance(s) with the LUT data buffer, LUT dimension, and the sampling key of the LUT. For more information, see [`LutProperties`](/reference/android/hardware/LutProperties) documentation.\n3. Call [`DisplayLuts#set(DisplayLuts.Entry luts)`](/reference/android/hardware/DisplayLuts#set(android.hardware.DisplayLuts.Entry)) or [`DisplayLuts#set(DisplayLuts.Entry first, DisplayLuts.Entry second)`](/reference/android/hardware/DisplayLuts#set(android.hardware.DisplayLuts.Entry,%20android.hardware.DisplayLuts.Entry)) to set LUT entries. The framework supports 1D LUT, 3D LUT, or a combination of 1D and 3D LUTs.\n4. Call [`SurfaceControl.Transaction#setLuts`](/reference/android/view/SurfaceControl.Transaction#setLuts(android.view.SurfaceControl,%20android.hardware.DisplayLuts)) to apply the LUTs to the layer.\n\n### Kotlin\n\n val sc = SurfaceControl.Builder().build()\n val luts = DisplayLuts()\n val entry = DisplayLuts.Entry(\n floatArrayOf(0.5f, 0.5f, 0.5f, 0.5f),\n LutProperties.ONE_DIMENSION,\n LutProperties.SAMPLING_KEY_MAX_RGB\n )\n luts.set(entry)\n SurfaceControl.Transaction().setLuts(sc, luts).apply()\n\n### Java\n\n SurfaceControl sc = new SurfaceControl.Builder().build();\n DisplayLuts luts = new DisplayLuts();\n DisplayLuts.Entry entry = new DisplayLuts.Entry(\n new float[]{0.5f, 0.5f, 0.5f, 0.5f},\n LutProperties.ONE_DIMENSION,\n LutProperties.SAMPLING_KEY_MAX_RGB\n );\n luts.set(entry);\n new SurfaceControl.Transaction().setLuts(sc, luts).apply();\n\nYou can also use [`OverlayProperties.getLutProperties()`](/reference/android/hardware/OverlayProperties#getLutProperties()) to understand the\nLUT properties of the device, and determine if the Hardware Composer can handle\nthe selected LUT."]]