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_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_IMAGE_PROVIDER_IMAGE_DATA_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_IMAGE_PROVIDER_IMAGE_DATA_H 18 19 #include "core/components/common/properties/color.h" 20 #include "core/components_ng/image_provider/svg_dom_base.h" 21 22 namespace OHOS::Ace::NG { 23 24 class ImageData : public AceType { 25 DECLARE_ACE_TYPE(ImageData, AceType); 26 public: ImageData(const RefPtr<PixelMap> & pixelMap)27 explicit ImageData(const RefPtr<PixelMap>& pixelMap) : pixelMap_(pixelMap) {} 28 ImageData() = default; 29 ~ImageData() override = default; 30 static RefPtr<ImageData> MakeFromDataWithCopy(const void* data, size_t length); 31 static RefPtr<ImageData> MakeFromDataWrapper(void* dataWrapper); 32 static RefPtr<ImageData> MakeFromPixelMap(const RefPtr<PixelMap>& pixelMap); 33 virtual size_t GetSize() const; 34 virtual const void* GetData() const; 35 36 bool HasPixelMapData(); 37 RefPtr<PixelMap>& GetPixelMapData(); 38 39 protected: 40 RefPtr<PixelMap> pixelMap_; 41 }; 42 43 } // namespace OHOS::Ace::NG 44 45 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_IMAGE_PROVIDER_IMAGE_DATA_H 46