openharmony 鸿蒙 js-apis-sendableColorSpaceManager

2025-06-12 浏览 (1)

@ohos.graphics.sendableColorSpaceManager (Sendable Color Space Management)

The sendableColorSpaceManager module provides APIs for creating and managing sendable color space objects and obtaining basic attributes of sendable color spaces.

NOTE

The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import { sendableColorSpaceManager } from '@kit.ArkGraphics2D';

ISendable

type ISendable = lang.ISendable

ISendable is the parent type of all sendable types except null and undefined. It does not have any necessary methods or properties.

System capability: SystemCapability.Utils.Lang

TypeDescription
lang.ISendableParent type of all sendable types.

sendableColorSpaceManager.create

create(colorSpaceName: colorSpaceManager.ColorSpace): ColorSpaceManager

Creates a standard color space object that is sendable.

System capability: SystemCapability.Graphic.Graphic2D.ColorManager.Core

Parameters

NameTypeMandatoryDescription
colorSpaceNamecolorSpaceManager.ColorSpaceYesType of the color space.
UNKNOWN and CUSTOM cannot be used when creating standard color space objects.

Return value

TypeDescription
ColorSpaceManagerSendable color space object created.
This instance inherits from ISendable and can be passed by reference between concurrent ArkTS instances (including the main thread and the worker threads of TaskPool or Worker). For details, see Using Sendable Objects.

Error codes

For details about the error codes, see Universal Error Codes and colorSpaceManager Error Codes.

IDError Message
401Parameter error. Possible cause: 1.Incorrect parameter type. 2.Parameter verification failed.
18600001The parameter value is abnormal.

Example

import { colorSpaceManager } from '@kit.ArkGraphics2D';
let colorSpace: sendableColorSpaceManager.ColorSpaceManager;
colorSpace = sendableColorSpaceManager.create(colorSpaceManager.ColorSpace.SRGB);

sendableColorSpaceManager.create

create(primaries: colorSpaceManager.ColorSpacePrimaries, gamma: number): ColorSpaceManager

Creates a custom color space object that is sendable.

System capability: SystemCapability.Graphic.Graphic2D.ColorManager.Core

Parameters

NameTypeMandatoryDescription
primariescolorSpaceManager.ColorSpacePrimariesYesPrimaries of the color space.
gammanumberYesGamma of the color space.

Return value

TypeDescription
ColorSpaceManagerSendable color space object created.
The color space type is CUSTOM, which is one of the enumerated values of colorSpaceManager.ColorSpace.
This instance inherits from ISendable and can be passed by reference between concurrent ArkTS instances (including the main thread and the worker threads of TaskPool or Worker). For details, see Using Sendable Objects.

Error codes

For details about the error codes, see Universal Error Codes and colorSpaceManager Error Codes.

IDError Message
401Parameter error. Possible cause: 1.Incorrect parameter type. 2.Parameter verification failed.
18600001The parameter value is abnormal.

Example

import { colorSpaceManager } from '@kit.ArkGraphics2D';
let colorSpace: sendableColorSpaceManager.ColorSpaceManager;
let primaries: colorSpaceManager.ColorSpacePrimaries = {
  redX: 0.1,
  redY: 0.1,
  greenX: 0.2,
  greenY: 0.2,
  blueX: 0.3,
  blueY: 0.3,
  whitePointX: 0.4,
  whitePointY: 0.4
};
let gamma: number = 2.2;
colorSpace = sendableColorSpaceManager.create(primaries, gamma);

ColorSpaceManager

Implements management of color space objects.

Before calling any of the following APIs, you must use create() to create a color space manager.

getColorSpaceName

getColorSpaceName(): colorSpaceManager.ColorSpace

Obtains the color space type.

System capability: SystemCapability.Graphic.Graphic2D.ColorManager.Core

Return value

TypeDescription
colorSpaceManager.ColorSpaceColor space type.

Error codes

For details about the error codes, see colorSpaceManager Error Codes.

IDError Message
18600001The parameter value is abnormal.

Example

let spaceName: colorSpaceManager.ColorSpace = colorSpace.getColorSpaceName();

getWhitePoint

getWhitePoint(): collections.Array<number>

Obtains the coordinates of the white point in the color space.

System capability: SystemCapability.Graphic.Graphic2D.ColorManager.Core

Return value

TypeDescription
collections.Array<number>Coordinates [x, y] of the white point.

Error codes

For details about the error codes, see colorSpaceManager Error Codes.

IDError Message
18600001The parameter value is abnormal.

Example

import { collections } from '@kit.ArkTS';
let point: collections.Array<number> = colorSpace.getWhitePoint();

getGamma

getGamma(): number

Obtains the gamma of the color space.

System capability: SystemCapability.Graphic.Graphic2D.ColorManager.Core

Return value

TypeDescription
numberGamma of the color space.

Error codes

For details about the error codes, see colorSpaceManager Error Codes.

IDError Message
18600001The parameter value is abnormal.

Example

let gamma: number = colorSpace.getGamma();

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkGraphics 2D

harmony 鸿蒙BufferHandle

harmony 鸿蒙ColorSpacePrimaries

harmony 鸿蒙DisplaySoloist_ExpectedRateRange

harmony 鸿蒙_drawing

harmony 鸿蒙NativeColorSpaceManager

harmony 鸿蒙NativeDisplaySoloist

harmony 鸿蒙NativeVsync

harmony 鸿蒙NativeWindow

harmony 鸿蒙OH_Drawing_BitmapFormat

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/Pd7FWz