• 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 #ifndef BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_IMAGE_UTIL_H
16 #define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_IMAGE_UTIL_H
17 
18 #include <memory>
19 #include <string>
20 #include "pixel_map.h"
21 
22 namespace OHOS {
23 namespace Notification {
24 class AnsImageUtil {
25 public:
26     static const std::string IMAGE_FORMAT_JPEG;
27     static const uint8_t IMAGE_QUALITY;
28     static const uint8_t SHIFT_FOUR;
29     static const uint8_t NUM_TEN;
30     static const size_t  TWO_TIMES;
31 
32     static std::string PackImage(
33         const std::shared_ptr<Media::PixelMap> &pixelMap, const std::string &format = IMAGE_FORMAT_JPEG);
34 
35     static std::shared_ptr<Media::PixelMap> UnPackImage(const std::string &pixelMapStr);
36 
37     static bool PackImage2File(
38         const std::shared_ptr<Media::PixelMap> &pixelMap,
39         const std::string &outFilePath,
40         const std::string &format = IMAGE_FORMAT_JPEG);
41 
42     static std::shared_ptr<Media::PixelMap> CreatePixelMap(
43         const std::string &inFilePath, const std::string &format = IMAGE_FORMAT_JPEG);
44 
45     static std::string BinToHex(const std::string &strBin);
46 
47     static std::string HexToBin(const std::string &strHex);
48 };
49 }  // namespace Notification
50 }  // namespace OHOS
51 
52 #endif  // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_IMAGE_UTIL_H
53