• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Multimedia Subsystem Changelog
2
3## cl.multimedia.1 Changed the System Capability of the desiredAuxiliaryPictures Property in Image.ImageSource.DecodingOptionsForPicture
4
5**Access Level**
6
7Public API
8
9**Reason for Change**
10
11The system capability of **desiredAuxiliaryPictures** is inconsistent with that of **DecodingOptionsForPicture**, which affects the judgment of the system capability supported. Therefore, the system capability of **desiredAuxiliaryPictures** is changed from SystemCapability.Multimedia.Image.Core to SystemCapability.Multimedia.Image.ImageSource.
12
13**Change Impact**
14
15This change is a non-compatible change.
16The system capability of the property is changed. The change does not affect the usage of the property.
17
18Before change: The system capability of **DecodingOptionsForPicture** is SystemCapability.Multimedia.Image.Core.
19
20After change: The system capability of **DecodingOptionsForPicture** is SystemCapability.Multimedia.Image.ImageSource.
21
22**Start API Level**
23
2413
25
26**Change Since**
27
28OpenHarmony 5.0.0.57
29
30**Key API/Component Changes**
31
32The following property in @ohos.multimedia.image are involved:
33
34| API| API Description| Property| Property Description|
35| -------- | -------- | -------- | -------- |
36|image.ImageSource.DecodingOptionsForPicture|Describes the image decoding options.|desiredAuxiliaryPictures|Auxiliary picture type. By default, all auxiliary picture types are decoded.|
37
38
39**Adaptation Guide**
40
41The value of **SystemCapability** for a property in an API must be the same as that of the API. If the **canIUse()** API is called in your code to check whether the system capability required for the involved API is supported, change the system capability passed. Specifically, to check whether the device supports the capability for image source decoding and parsing, call **canIUse("SystemCapability.Multimedia.Image.ImageSource")**.
42
43## cl.multimedia.2 Changed the Behavior of image.Component.OH_AuxiliaryPictureNative_SetInfo()
44
45**Access Level**
46
47Public API
48
49**Reason for Change**
50
51When **OH_AuxiliaryPictureNative_SetInfo** is called to set auxiliary image information, the size and pixel format in the auxiliary image information is synchronized to ImageInfo of the PixelMap. The size and pixel format should be verified to prevent out-of-bounds access to the PixelMap data.
52
53**Change Impact**
54
55This change is a non-compatible change.
56
57Before change: When **OH_AuxiliaryPictureNative_SetInfo()** is called to set auxiliary image information, the pixel format passed is not verified.
58
59After change: When **OH_AuxiliaryPictureNative_SetInfo()** is used to set auxiliary image information, the setting fails and error code 401 is returned if the number of bytes for storing pixels is increased. For example, if the API is called to set **pixelFormat** from RGBA_8888 to RGBA_F16, the error code is reported.
60
61**Start API Level**
62
6313
64
65**Change Since**
66
67OpenHarmony 5.0.0.57
68
69**Key API/Component Changes**
70
71API in picture_native.h:
72
73Image_ErrorCode OH_AuxiliaryPictureNative_SetInfo(OH_AuxiliaryPictureNative *auxiliaryPicture,    OH_AuxiliaryPictureInfo *info);
74
75**Adaptation Guide**
76
77If the number of bytes for storing pixels is increased when setting auxiliary image information, the setting fails and error code 401 is returned.
78
79```c++
80size_t filePathSize = 1024;
81OH_ImageSourceNative* imageSource = nullptr;
82Image_ErrorCode image_ErrorCode = OH_ImageSourceNative_CreateFromUri("test.jpg", filePathSize, &imageSource);
83if (image_ErrorCode != Image_ErrorCode::IMAGE_SUCCESS || imageSource == nullptr) {
84    H_LOGE("OH_ImageSourceNative_CreateFromUri failed.");
85}
86OH_DecodingOptionsForPicture *opts = nullptr;
87OH_DecodingOptionsForPicture_Create(&opts);
88OH_PictureNative *picture = nullptr;
89image_ErrorCode = OH_ImageSourceNative_CreatePicture(imageSource, opts, &picture);
90OH_ImageSourceNative_Release(imageSource);
91OH_DecodingOptionsForPicture_Release(opts);
92if (image_ErrorCode != Image_ErrorCode::IMAGE_SUCCESS || picture == nullptr) {
93    H_LOGE("OH_ImageSourceNative_CreatePicture failed. image_ErrorCode=%{public}d", image_ErrorCode);
94}
95OH_AuxiliaryPictureNative *auxiliaryPicture = nullptr;
96image_ErrorCode = OH_PictureNative_GetAuxiliaryPicture(
97    picture, Image_AuxiliaryPictureType::AUXILIARY_PICTURE_TYPE_FRAGMENT_MAP, &auxiliaryPicture);
98if (image_ErrorCode != Image_ErrorCode::IMAGE_SUCCESS || auxiliaryPicture == nullptr) {
99    H_LOGE("OH_PictureNative_GetAuxiliaryPicture failed. image_ErrorCode=%{public}d", image_ErrorCode);
100}
101OH_AuxiliaryPictureInfo *auxInfo = nullptr;
102image_ErrorCode = OH_AuxiliaryPictureNative_GetInfo(auxiliaryPicture, &auxInfo);
103PIXEL_FORMAT newPixelFormat = PIXEL_FORMAT_RGBA_F16;
104OH_AuxiliaryPictureInfo_SetPixelFormat(auxInfo, newPixelFormat);
105image_ErrorCode = OH_AuxiliaryPictureNative_SetInfo(auxiliaryPicture, auxInfo);
106if (image_ErrorCode != Image_ErrorCode::IMAGE_SUCCESS || info == nullptr) {
107    H_LOGE("OH_AuxiliaryPictureNative_SetInfo failed. image_ErrorCode=%{public}d", image_ErrorCode);
108}
109OH_AuxiliaryPictureInfo_Release(auxInfo);
110OH_AuxiliaryPictureNative_Release(auxiliaryPicture);
111```
112
113## cl.multimedia.3 Changed the Behavior of image.Component.setAuxiliaryPictureInfo
114
115**Access Level**
116
117Public API
118
119**Reason for Change**
120
121When **setAuxiliaryPictureInfo** is called to set auxiliary image information, the size and pixel format in the auxiliary image information is synchronized to ImageInfo of the PixelMap. The size and pixel format should be verified to prevent out-of-bounds access to the PixelMap data.
122
123**Change Impact**
124
125This change is a non-compatible change.
126
127Before change: When **setAuxiliaryPictureInfo()** is called to set auxiliary image information, the pixel format passed is not verified.
128
129After change: When **setAuxiliaryPictureInfo()** is used to set auxiliary image information, the setting fails and error code 401 is returned if the number of bytes for storing pixels is increased. For example, if the API is called to set **pixelFormat** from RGBA_8888 to RGBA_F16, the error code is reported.
130
131**Start API Level**
132
13313
134
135**Change Since**
136
137OpenHarmony 5.0.0.57
138
139**Key API/Component Changes**
140
141API in @ohos.multimedia.image.d.ts:
142
143setAuxiliaryPictureInfo(info: AuxiliaryPictureInfo): void
144
145**Adaptation Guide**
146
147If the number of bytes for storing pixels is increased when setting auxiliary image information, the setting fails and error code 401 is returned.
148
149```ts
150const context = getContext(this);
151const resourceMgr = context.resourceManager;
152const rawFile = await resourceMgr.getRawFileContent('test.jpg');
153let imageSource: image.ImageSource = image.createImageSource(rawFile.buffer as ArrayBuffer);
154let options: image.DecodingOptionsForPicture = {
155  desiredAuxiliaryPictures: [image.AuxiliaryPictureType.FRAGMENT_MAP]
156};
157try {
158  let picture: image.Picture = await imageSource.createPicture(options);
159  let auxiliaryPicture = picture.getAuxiliaryPicture(image.AuxiliaryPictureType.FRAGMENT_MAP);
160  let originInfo = auxiliaryPicture?.getAuxiliaryPictureInfo();
161  console.info("CreatePicture", 'originInfo = ' + JSON.stringify(originInfo));
162  let changedInfo: image.AuxiliaryPictureInfo = {
163    auxiliaryPictureType: image.AuxiliaryPictureType.FRAGMENT_MAP,
164    size: { height: 410, width: 3072 },
165    rowStride: 3072 * 8,
166    pixelFormat: image.PixelMapFormat.RGBA_F16,
167    colorSpace: colorSpaceManager.create(colorSpaceManager.ColorSpace.DCI_P3),
168  };
169  try {
170    auxiliaryPicture?.setAuxiliaryPictureInfo(changedInfo);
171    console.info("CreatePicture", ' changedInfo = ' + JSON.stringify(changedInfo));
172  } catch (error) {
173    console.error("CreatePicture", 'setAuxiliaryPictureInfo', ` failed error.code: ` + JSON.stringify(error.code)
174      + ` error.message: ` + JSON.stringify(error.message));
175  }
176} catch (err) {
177  console.error("CreatePicture", ' decode Picture failed !!!');
178}
179```
180