1 /* 2 * Copyright (C) 2023 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 FOUNDATION_ACE_INTERFACE_INNERKITS_IMAGE_CONVERTER_H 16 #define FOUNDATION_ACE_INTERFACE_INNERKITS_IMAGE_CONVERTER_H 17 18 #include "include/core/SkBitmap.h" 19 #include "include/core/SkImageInfo.h" 20 #ifdef NEW_SKIA 21 #include "include/core/SkSamplingOptions.h" 22 #endif 23 #ifndef PREVIEW 24 #include "pixel_map.h" 25 #include "image_source.h" 26 #else 27 #include "image_source_preview.h" 28 #endif 29 30 namespace OHOS::Ace::Napi { 31 class ImageConverter { 32 public: 33 std::unique_ptr<Media::ImageSource> CreateImageSource(const char* item, uint32_t& errorCode); 34 static SkColorType PixelFormatToSkColorType(Media::PixelFormat pixelFormat); 35 static SkAlphaType AlphaTypeToSkAlphaType(Media::AlphaType alphaType); 36 static std::shared_ptr<SkBitmap> PixelMapToBitmap( 37 const std::shared_ptr<Media::PixelMap>& pixelMap); 38 static std::shared_ptr<Media::PixelMap> BitmapToPixelMap( 39 const std::shared_ptr<SkBitmap>& bitMap, Media::InitializationOptions& opts); 40 }; 41 } // namespace OHOS::Ace::Napi 42 #endif // #define FOUNDATION_ACE_INTERFACE_INNERKITS_IMAGE_CONVERTER_H 43 44