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_SERVICES_THUMBNAIL_SERVICE_INCLUDE_THUMBNAIL_IMAGE_FRAMEWORK_UTILS_H_ 17 #define FRAMEWORKS_SERVICES_THUMBNAIL_SERVICE_INCLUDE_THUMBNAIL_IMAGE_FRAMEWORK_UTILS_H_ 18 19 #include "picture.h" 20 #include "surface_buffer.h" 21 22 #include "exif_rotate_utils.h" 23 24 namespace OHOS { 25 namespace Media { 26 #define EXPORT __attribute__ ((visibility ("default"))) 27 28 class ThumbnailImageFrameWorkUtils { 29 public: 30 EXPORT ThumbnailImageFrameWorkUtils() = delete; 31 EXPORT virtual ~ThumbnailImageFrameWorkUtils() = delete; 32 33 EXPORT static bool IsYuvPixelMap(std::shared_ptr<PixelMap> pixelMap); 34 EXPORT static bool IsSupportCopyPixelMap(std::shared_ptr<PixelMap> pixelMap); 35 EXPORT static std::shared_ptr<Picture> CopyPictureSource(std::shared_ptr<Picture> picture); 36 EXPORT static std::shared_ptr<PixelMap> CopyPixelMapSource(std::shared_ptr<PixelMap> pixelMap); 37 EXPORT static bool IsSupportGenAstc(); 38 EXPORT static bool IsPictureValid(const std::shared_ptr<Picture>& picture); 39 EXPORT static bool IsPixelMapValid(const std::shared_ptr<PixelMap>& pixelMap); 40 EXPORT static std::shared_ptr<Picture> CopyAndScalePicture(const std::shared_ptr<Picture>& picture, 41 const Size& desiredSize); 42 EXPORT static std::shared_ptr<PixelMap> CopyAndScalePixelMap(const std::shared_ptr<PixelMap>& pixelMap, 43 const Size& desiredSize); 44 EXPORT static bool FlipAndRotatePicture(std::shared_ptr<Picture> picture, int32_t exifRotate); 45 EXPORT static bool FlipAndRotatePicture(std::shared_ptr<Picture> picture, const FlipAndRotateInfo &info); 46 EXPORT static bool FlipAndRotatePixelMap(std::shared_ptr<PixelMap> pixelMap, int32_t exifRotate); 47 EXPORT static bool FlipAndRotatePixelMap(std::shared_ptr<PixelMap> pixelMap, const FlipAndRotateInfo &info); 48 49 private: 50 EXPORT static std::shared_ptr<PixelMap> CopyNormalPixelmap(std::shared_ptr<PixelMap> pixelMap); 51 EXPORT static std::shared_ptr<PixelMap> CopyYuvPixelmap(std::shared_ptr<PixelMap> pixelMap); 52 EXPORT static std::shared_ptr<PixelMap> CopyYuvPixelmapWithSurfaceBuffer(std::shared_ptr<PixelMap> pixelMap); 53 EXPORT static std::shared_ptr<PixelMap> CopyNoSurfaceBufferYuvPixelmap(std::shared_ptr<PixelMap> pixelMap); 54 EXPORT static bool SetPixelMapYuvInfo(sptr<SurfaceBuffer> &surfaceBuffer, 55 std::shared_ptr<PixelMap> pixelMap, bool isHdr); 56 EXPORT static void CopySurfaceBufferInfo(sptr<SurfaceBuffer> &source, sptr<SurfaceBuffer> &dst); 57 EXPORT static bool GetSbStaticMetadata(const sptr<SurfaceBuffer> &buffer, std::vector<uint8_t> &staticMetadata); 58 EXPORT static bool GetSbDynamicMetadata(const sptr<SurfaceBuffer> &buffer, std::vector<uint8_t> &dynamicMetadata); 59 EXPORT static bool SetSbStaticMetadata(sptr<SurfaceBuffer> &buffer, const std::vector<uint8_t> &staticMetadata); 60 EXPORT static bool SetSbDynamicMetadata(sptr<SurfaceBuffer> &buffer, const std::vector<uint8_t> &dynamicMetadata); 61 }; 62 } // namespace Media 63 } // namespace OHOS 64 65 #endif // FRAMEWORKS_SERVICES_THUMBNAIL_SERVICE_INCLUDE_THUMBNAIL_IMAGE_FRAMEWORK_UTILS_H_ 66