1 /* 2 * Copyright (C) 2025 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 FRAMEWORKS_KITS_TAIHE_INCLUDE_IMAGE_TAIHE_UTILS_H 17 #define FRAMEWORKS_KITS_TAIHE_INCLUDE_IMAGE_TAIHE_UTILS_H 18 19 #include "image_source.h" 20 #include "image_type.h" 21 #include "ohos.multimedia.image.image.proj.hpp" 22 #include "ohos.multimedia.image.image.impl.hpp" 23 #include "taihe/runtime.hpp" 24 25 namespace ANI::Image { 26 using namespace taihe; 27 using namespace ohos::multimedia::image::image; 28 29 class ImageTaiheUtils { 30 public: 31 static void HicheckerReport(); 32 static void ThrowExceptionError(const std::string errMsg); 33 static void ThrowExceptionError(const int32_t errCode, const std::string errMsg); 34 struct ImagePropertyOptions { 35 uint32_t index = 0; 36 std::string defaultValueStr; 37 }; 38 39 static bool GetPropertyDouble(ani_env *env, ani_object obj, const std::string &name, double &value); 40 static ani_object ToBusinessError(ani_env *env, int32_t code, const std::string &message); 41 42 static OHOS::Media::SourceOptions ParseSourceOptions(SourceOptions const& options); 43 static ImageInfo ToTaiheImageInfo(const OHOS::Media::ImageInfo &src, bool isHdr); 44 static array<string> ToTaiheArrayString(const std::vector<std::string> &src); 45 static array<uint8_t> CreateTaiheArrayBuffer(uint8_t* src, size_t srcLen); 46 static uintptr_t GetUndefinedPtr(ani_env *env); 47 48 template <typename EnumType, typename ValueType> 49 static bool GetEnumKeyByValue(ValueType value, typename EnumType::key_t &key); 50 }; 51 } // namespace ANI::Image 52 53 #endif // FRAMEWORKS_KITS_TAIHE_INCLUDE_IMAGE_TAIHE_UTILS_H