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 COLOR 17 #define COLOR 18 19 #include "color_space_convertor.h" 20 21 namespace OHOS { 22 namespace ColorManager { 23 class Color { 24 public: Color()25 Color() {}; 26 Color(float r, float g, float b, float a); 27 Color(float r, float g, float b, float a, const ColorSpaceName name); 28 explicit Color(unsigned int color); 29 explicit Color(uint64_t color); 30 31 // Packs the 3 RGBA into a color int in the specified color space. 32 uint64_t PackValue() const; 33 34 Color Convert(ColorSpaceConvertor &convertor) const; 35 Color Convert(const ColorSpace &dst) const; 36 Color Convert(ColorSpaceName colorSpaceName) const; 37 bool ColorEqual(const Color &val) const; 38 39 float r = 0.0f; 40 float g = 0.0f; 41 float b = 0.0f; 42 float a = 0.0f; 43 ColorSpaceName srcName = ColorSpaceName::SRGB; 44 }; 45 } // namespace ColorManager 46 } // namespace OHOS 47 #endif 48