1 /* 2 * Copyright (c) 2024 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 COLOR_PICKER_COMMON_H 16 #define COLOR_PICKER_COMMON_H 17 18 #include <vector> 19 20 #include "color.h" 21 #include "color_picker.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 class ColorPickerCommon { 26 public: 27 static std::shared_ptr<Rosen::ColorPickerCommon> CreateColorPicker( 28 const std::shared_ptr<Media::PixelMap>& pixmap, uint32_t& errorCode); 29 static std::shared_ptr<Rosen::ColorPickerCommon> CreateColorPicker( 30 const std::shared_ptr<Media::PixelMap>& pixmap, std::vector<double> region, uint32_t& errorCode); 31 static uint32_t GetMainColor(ColorManager::Color& color); 32 static uint32_t GetLargestProportionColor(ColorManager::Color& color); 33 static uint32_t GetHighestSaturationColor(ColorManager::Color& color); 34 static uint32_t GetAverageColor(ColorManager::Color& color); 35 static bool IsBlackOrWhiteOrGrayColor(uint32_t color, uint32_t& errorCode); 36 static std::vector<ColorManager::Color> GetTopProportionColors(double colorCount, uint32_t& errorCode); 37 std::shared_ptr<ColorPicker> nativeColorPicker_; 38 std::shared_ptr<ColorPicker> sColorPicker_; 39 static thread_local std::shared_ptr<ColorPickerCommon> sConstructor_; 40 }; 41 } // namespace Rosen 42 } // namespace OHOS 43 44 #endif /* COLOR_PICKER_COMMON_H */