• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_APPEXECFWK_SERVICES_DBMS_INCLUDE_IMAGE_BUFFER_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_DBMS_INCLUDE_IMAGE_BUFFER_H
18 
19 #include <cstring>
20 
21 namespace OHOS {
22 namespace AppExecFwk {
23 typedef unsigned char ImageData;
24 typedef unsigned char* ImageRow;
25 typedef unsigned char** ImageMap;
26 
27 class ImageBuffer {
28 public:
29     ImageBuffer() = default;
30     ~ImageBuffer();
31     bool MallocImageMap(int components);
GetWidth()32     uint32_t GetWidth() const
33     {
34         return width;
35     }
SetWidth(uint32_t width)36     void SetWidth(uint32_t width)
37     {
38         this->width = width;
39     }
GetHeight()40     uint32_t GetHeight() const
41     {
42         return height;
43     }
SetHeight(uint32_t height)44     void SetHeight(uint32_t height)
45     {
46         this->height = height;
47     }
GetFileSize()48     uint32_t GetFileSize() const
49     {
50         return fileSize;
51     }
SetFileSize(uint32_t fileSize)52     void SetFileSize(uint32_t fileSize)
53     {
54         this->fileSize = fileSize;
55     }
GetComponents()56     uint32_t GetComponents() const
57     {
58         return components;
59     }
SetComponents(uint32_t components)60     void SetComponents(uint32_t components)
61     {
62         this->components = components;
63     }
GetPngComponents()64     uint32_t GetPngComponents() const
65     {
66         return pngComponents;
67     }
SetPngComponents(uint32_t pngComponents)68     void SetPngComponents(uint32_t pngComponents)
69     {
70         this->pngComponents = pngComponents;
71     }
GetRatio()72     double GetRatio() const
73     {
74         return ratio;
75     }
SetRatio(double ratio)76     void SetRatio(double ratio)
77     {
78         this->ratio = ratio;
79     }
GetColorType()80     ImageData GetColorType() const
81     {
82         return colorType;
83     }
SetColorType(ImageData colorType)84     void SetColorType(ImageData colorType)
85     {
86         this->colorType = colorType;
87     }
GetBitDepth()88     ImageData GetBitDepth() const
89     {
90         return bitDepth;
91     }
SetBitDepth(ImageData bitDepth)92     void SetBitDepth(ImageData bitDepth)
93     {
94         this->bitDepth = bitDepth;
95     }
GetImageDataPointer()96     std::unique_ptr<unsigned char[]>& GetImageDataPointer()
97     {
98         return imageDataPointer;
99     }
SetImageType(const std::string & type)100     void SetImageType(const std::string& type)
101     {
102         imageType = type;
103     }
GetImageType()104     const std::string& GetImageType() const
105     {
106         return imageType;
107     }
GetCompressDataBuffer()108     std::unique_ptr<unsigned char[]>& GetCompressDataBuffer()
109     {
110         return compressDataBuffer;
111     }
GetCompressSize()112     int32_t GetCompressSize() const
113     {
114         return compressSize;
115     }
SetCompressSize(int32_t compressSize)116     void SetCompressSize(int32_t compressSize)
117     {
118         this->compressSize = compressSize;
119     }
120     int32_t SetCompressData(unsigned char* buffer, int32_t length);
121 
122 private:
123     uint32_t width;
124     uint32_t height;
125     uint32_t fileSize;
126     uint32_t components;
127     uint32_t pngComponents;
128     double ratio;
129     ImageData colorType;
130     ImageData bitDepth;
131     std::unique_ptr<unsigned char[]> imageDataPointer = nullptr;
132     std::unique_ptr<unsigned char[]> compressDataBuffer = nullptr;
133     std::string imageType;
134     int32_t compressSize;
135 };
136 }  // namespace AppExecFwk
137 }  // namespace OHOS
138 
139 #endif  // FOUNDATION_APPEXECFWK_SERVICES_DBMS_INCLUDE_IMAGE_BUFFER_H