自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
廣色域擷取
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
對於搭載 Android 14 以上版本的裝置,Android 支援 Display P3 廣色域擷取功能。裝置可使用 ImageReader
類別,以 JPEG 格式擷取寬色域色彩圖片,而無須使用 10 位元 HDR。這項功能可讓裝置透過 SessionConfiguration
中的 setColorSpace
參數,向 Camera2 架構要求以廣色域色彩空間擷取相機畫面。
需求條件
如要支援廣色域擷取功能,裝置必須具備廣色域色彩功能的相機。
實作
如要支援 Display P3 廣色域擷取要求,請執行下列操作:
- 讀取
Stream.aidl
中的 colorSpace
欄位,並將其套用至輸出串流。
- 實作
android.request.availableColorSpaceProfilesMap
中繼資料項目。
- 在
android.request.availableCapabilities
中回報 COLOR_SPACE_PROFILES
功能。
如需支援 P3 廣色域擷取的相機 HAL 參考實作,請參閱 /hardware/google/camera/devices/EmulatedCamera/hwl/
configs/emu_camera_back.json
中的以下內容:
如要進一步瞭解 Camera HAL 中的寬廣色域擷取功能,請參閱 metadata_definitions.xml
中的以下值:
API
對於搭載 Android 14 以上版本且支援廣色域擷取功能的裝置,相機用戶端可以使用下列公開 API:
ColorSpace
參數的預期值會衍生自 ColorSpace.Named
類別。Android 14 支援 SRGB
、DISPLAY_P3
和 BT2020_HLG
。
驗證
如要驗證您是否已實作 Display P3 廣色域擷取支援功能,請執行下列測試。
CTS
android.hardware.camera2.cts.ExtendedCameraCharacteristicsTest#test8BitColorSpaceOutputCharacteristics
android.hardware.camera2.cts.ExtendedCameraCharacteristicsTest#test10BitColorSpaceOutputCharacteristics
android.hardware.camera2.cts.ExtendedCameraCharacteristicsTest#testColorSpaceProfileMap
android.hardware.camera2.cts.ImageReaderTest#testDisplayP3Jpeg
android.hardware.camera2.cts.ImageReaderTest#testDisplayP3JpegRepeating
android.hardware.camera2.cts.ImageReaderTest#testDisplayP3Heic
android.hardware.camera2.cts.ImageReaderTest#testDisplayP3HeicRepeating
ITS
執行 Camera Image Test Suite (ITS) 測試,驗證下列項目:
- 存在含有正確色度座標的 ICC 色彩描述檔
- 圖片包含超出 sRGB 色域的像素資料
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-26 (世界標準時間)。"],[],[],null,["# Wide gamut capture\n\nFor devices running Android 14 or higher, Android\nprovides support for Display P3 wide gamut capture. Devices can capture wide\ngamut color images in JPEG format with the `ImageReader` class without\nusing [10-bit HDR](/docs/core/camera/10-bit-camera-output). This feature lets\ndevices\nrequest camera capture in a wide gamut color space to the Camera2 framework\nthrough the [`setColorSpace`](https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration#setColorSpace(android.graphics.ColorSpace.Named)) parameter in `SessionConfiguration`.\n\nRequirements\n------------\n\nTo support wide gamut capture, the device must have access to a camera with wide\ngamut color capabilities.\n\nImplementation\n--------------\n\nTo support Display P3 wide gamut capture requests, do the following:\n\n- Read the `colorSpace` field in [`Stream.aidl`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/camera/device/aidl/android/hardware/camera/device/Stream.aidl) and apply it to the output stream.\n- Implement the `android.request.availableColorSpaceProfilesMap` metadata entry.\n- Report the `COLOR_SPACE_PROFILES` capability in `android.request.availableCapabilities`.\n\nFor a reference Camera HAL implementation supporting P3 wide gamut capture,\nsee the following in `/hardware/google/camera/devices/EmulatedCamera/hwl/\nconfigs/emu_camera_back.json`:\n\n- [`android.request.availableCapabilities`](https://android.googlesource.com/platform/hardware/google/camera/+/refs/heads/android16-release/devices/EmulatedCamera/hwl/configs/emu_camera_back.json#183)\n- [`android.request.availableColorSpaceProfilesMap`](https://android.googlesource.com/platform/hardware/google/camera/+/refs/heads/android16-release/devices/EmulatedCamera/hwl/configs/emu_camera_back.json#211)\n\nFor further details on wide gamut capture in the Camera HAL, see the following\nvalues in `metadata_definitions.xml`:\n\n- [`availableColorSpaceProfiles`](https://android.googlesource.com/platform/system/media/+/refs/heads/android16-release/camera/docs/metadata_definitions.xml#7163)\n- [`availableColorSpaceProfilesMap`](https://android.googlesource.com/platform/system/media/+/refs/heads/android16-release/camera/docs/metadata_definitions.xml#7184)\n- [`COLOR_SPACE_PROFILES`](https://android.googlesource.com/platform/system/media/+/refs/heads/android16-release/camera/docs/metadata_definitions.xml#6610)\n\n### APIs\n\nFor devices running Android 14 or higher with support\nfor wide gamut capture, camera clients can use the following public APIs:\n\n- [`ColorSpaceProfiles`](https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceProfiles)\n- [`setColorSpace`](https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration#setColorSpace(android.graphics.ColorSpace.Named))\n\nThe expected values for the `ColorSpace` parameter are derived from the\n[`ColorSpace.Named`](https://developer.android.com/reference/kotlin/android/graphics/ColorSpace.Named)\nclass. In Android 14, `SRGB`, `DISPLAY_P3`,\nand `BT2020_HLG` are supported.\n\nValidation\n----------\n\nTo validate your implementation of Display P3 wide gamut capture support, run\nthe following tests.\n\n### CTS\n\n- `android.hardware.camera2.cts.ExtendedCameraCharacteristicsTest#test8BitColorSpaceOutputCharacteristics`\n- `android.hardware.camera2.cts.ExtendedCameraCharacteristicsTest#test10BitColorSpaceOutputCharacteristics`\n- `android.hardware.camera2.cts.ExtendedCameraCharacteristicsTest#testColorSpaceProfileMap`\n- `android.hardware.camera2.cts.ImageReaderTest#testDisplayP3Jpeg`\n- `android.hardware.camera2.cts.ImageReaderTest#testDisplayP3JpegRepeating`\n- `android.hardware.camera2.cts.ImageReaderTest#testDisplayP3Heic`\n- `android.hardware.camera2.cts.ImageReaderTest#testDisplayP3HeicRepeating`\n\n### ITS\n\nRun the\n[Camera Image Test Suite (ITS)](/docs/compatibility/cts/camera-its)\ntests to validate the following:\n\n- Presence of an ICC profile with correct chromaticity coordinates\n- Image contains pixel data outside the sRGB gamut"]]