When an application is in a post-processing or video encoding scenario, the processed images or videos may exhibit abnormal effects such as color cast and overexposure.
When processing preview stream data or video recording stream data, you must handle the color space correctly. Otherwise, the processed data may exhibit abnormal effects such as color cast and overexposure. The specific causes are as follows:
The application does not actively set the color space, so the SDR color space is used by default, but the HDR format is used when configuring the camera output stream.
The application actively sets the color space, but uses a format that does not match the current color space when configuring the camera output stream data.
Call getActiveColorSpace (ArkTS) or OH_CaptureSession_GetActiveColorSpace (C/C++) to query the color space currently in effect for the camera session, and configure the correct color space information when processing the camera output stream data.
Based on the queried colorSpace information, the camera application can configure the corresponding color space parameters through the setColorSpace-related APIs.
ImageReceiver scenario (ArkTS): If you use ImageReceiver to receive images, first convert the Image data returned by the underlying layer through the imageArrival event listener into a PixelMap for image data processing or display. After creating the PixelMap, you can set the color space property of the image through setColorSpace.
NativeWindow scenario (C/C++): If you use NativeWindow to copy the preview stream or video recording stream data obtained from the camera, to avoid losing the color space property during data copying, you can first obtain the OHNativeWindow color space property through OH_NativeWindow_GetColorSpace, and then set the NativeWindow color space property through OH_NativeWindow_SetColorSpace.