1#  Graphics Subsystem Changelog
2
3## cl.graphics.1 Image APIs OH_GetImageInfo() and OH_PixelMap_GetImageInfo() Changed
4
5**Access Level**
6
7Public
8
9**Reason for Change**
10
11During hardware decoding for JPEG images, Direct Memory Access (DMA) is used, which is an aligned memory. Therefore, the method for calculating **rowSize** in **OH_GetImageInfo()** and **OH_PixelMap_GetImageInfo()** is changed.
12
13**Change Impact**
14
15This change is incompatible with earlier versions. The method for calculating **rowSize** is changed.
16
17**API Level**
18
19<11>
20
21**Change Since**
22
23OpenHarmony SDK 4.1.3.1
24
25**rowSize Component**
26
27Before change:
28
29**rowSize**: number of bytes per row. Calculation formula: Image width x Number of bytes in each pixel.
30
31After change:
32
33**rowSize**: number of bytes per row. In the case of DMA, the formula is as follows: Image width x Roundup(64 x Number of bytes per pixel). (The roundup means that each row is automatically padded.) In the case of other types of memory, the formula is as follows: Image width x Number of bytes per pixel.
34
35**Adaptation Guide**
36
37Scenario: The memory address of the pixel map is obtained by calling **OH_PixelMap_AccessPixels()**. When you directly operate the memory, adjust **rowSize**.
38
39Case 1: When OpenCV uses the pixel map data to construct **cv::Mat**, it must include the input parameter **step**.
40
41Before change:
42
43```c++
44cv::Mat srv(rows: bitmap.height, cols: bitmap.width, type: CV_8UC4, data: imagePixels);
45```
46
47After change:
48
49```c++
50cv::Mat srv(rows: bitmap.height, cols: bitmap.width, type: CV_8UC4, data: imagePixels, step: rowSize);
51```
52
53Case 2: When you copy the pixel map data, do not include the padding.
54
55```c++
56for (int i = 0; i < imageInfo_.size.height; ++i) {
57    errno_t ret = memcpy_s(dst, rowDataSize_, src_ + i * rowStride_, rowDataSize_);
58    if (ret != 0) {
59        Hilog::Error(LABLE, "read pixels by buffer memcpy the pixelmap data to dst fail, error:%{public}d", ret);
60        return ERROR_IMAGE_READ_PIXECLMAP_FAILED;
61    }
62    dst += rowDataSize_;
63}
64```
65