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_SOURCE_TAIHE_H 17 #define FRAMEWORKS_KITS_TAIHE_INCLUDE_IMAGE_SOURCE_TAIHE_H 18 19 #include "image_packer_taihe.h" 20 #include "image_source.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 ImageSourceImpl { 30 public: 31 ImageSourceImpl(); 32 explicit ImageSourceImpl(std::shared_ptr<OHOS::Media::ImageSource> imageSource); 33 ~ImageSourceImpl(); 34 int64_t GetImplPtr(); 35 36 ImageInfo GetImageInfoSyncWithIndex(uint32_t index); 37 ImageInfo GetImageInfoSync(); 38 PixelMap CreatePixelMapSyncWithOptions(DecodingOptions const& options); 39 PixelMap CreatePixelMapSync(); 40 PixelMap CreatePixelMapUsingAllocatorSync(optional_view<DecodingOptions> options, 41 optional_view<AllocatorType> allocatorType); 42 array<PixelMap> CreatePixelMapListSync(); 43 array<PixelMap> CreatePixelMapListSyncWithOptions(DecodingOptions const& options); 44 array<PixelMap> CreatePixelMapListSyncWithOptionalOptions(optional_view<DecodingOptions> options); 45 array<int32_t> GetDelayTimeListSync(); 46 string GetImagePropertySync(PropertyKey key, optional_view<ImagePropertyOptions> options); 47 map<PropertyKey, PropertyValue> GetImagePropertiesSync(array_view<PropertyKey> key); 48 void ModifyImagePropertySync(PropertyKey key, string_view value); 49 void ModifyImagePropertiesSync(map_view<PropertyKey, PropertyValue> records); 50 void ReleaseSync(); 51 52 array<string> GetSupportedFormats(); 53 54 std::shared_ptr<OHOS::Media::ImageSource> nativeImgSrc = nullptr; GetIncrementalPixelMap()55 std::shared_ptr<OHOS::Media::IncrementalPixelMap> GetIncrementalPixelMap() const 56 { 57 return navIncPixelMap_; 58 } 59 60 static thread_local std::string filePath_; 61 static thread_local int fileDescriptor_; 62 static thread_local void* fileBuffer_; 63 static thread_local size_t fileBufferSize_; 64 private: 65 std::shared_ptr<OHOS::Media::IncrementalPixelMap> navIncPixelMap_; 66 bool isRelease = false; 67 }; 68 } // namespace ANI::Image 69 70 #endif // FRAMEWORKS_KITS_TAIHE_INCLUDE_IMAGE_SOURCE_TAIHE_H