| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_COMMON_GFX_COLOR_UTILS_H__ | |
| 6 #define CHROME_COMMON_GFX_COLOR_UTILS_H__ | |
| 7 | |
| 8 #include "SkColor.h" | |
| 9 | |
| 10 class SkBitmap; | |
| 11 | |
| 12 namespace color_utils { | |
| 13 | |
| 14 // Represents set of CIE XYZ tristimulus values. | |
| 15 struct CIE_XYZ { | |
| 16 double X; | |
| 17 double Y; // luminance | |
| 18 double Z; | |
| 19 }; | |
| 20 | |
| 21 // Represents a L*a*b* color value | |
| 22 struct LabColor { | |
| 23 int L; | |
| 24 int a; | |
| 25 int b; | |
| 26 }; | |
| 27 | |
| 28 // Note: these transformations assume sRGB as the source color space | |
| 29 | |
| 30 // Convert between different color spaces | |
| 31 void SkColorToCIEXYZ(SkColor c, CIE_XYZ* xyz); | |
| 32 void CIEXYZToLabColor(const CIE_XYZ& xyz, LabColor* lab); | |
| 33 | |
| 34 SkColor CIEXYZToSkColor(SkAlpha alpha, const CIE_XYZ& xyz); | |
| 35 void LabColorToCIEXYZ(const LabColor& lab, CIE_XYZ* xyz); | |
| 36 | |
| 37 void SkColorToLabColor(SkColor c, LabColor* lab); | |
| 38 SkColor LabColorToSkColor(const LabColor& lab, SkAlpha alpha); | |
| 39 | |
| 40 // Determine if a given alpha value is nearly completely transparent. | |
| 41 bool IsColorCloseToTransparent(SkAlpha alpha); | |
| 42 | |
| 43 // Determine if a color is near grey. | |
| 44 bool IsColorCloseToGrey(int r, int g, int b); | |
| 45 | |
| 46 // Gets a color representing a bitmap. The definition of "representing" is the | |
| 47 // average color in the bitmap. The color returned is modified to have the | |
| 48 // specified alpha. | |
| 49 SkColor GetAverageColorOfFavicon(SkBitmap* bitmap, SkAlpha alpha); | |
| 50 | |
| 51 // Builds a histogram based on the Y' of the Y'UV representation of | |
| 52 // this image. | |
| 53 void BuildLumaHistogram(SkBitmap* bitmap, int histogram[256]); | |
| 54 | |
| 55 // Create a color from a base color and a specific alpha value. | |
| 56 SkColor SetColorAlpha(SkColor c, SkAlpha alpha); | |
| 57 | |
| 58 // Gets a Windows system color as a SkColor | |
| 59 SkColor GetSysSkColor(int which); | |
| 60 | |
| 61 } // namespace color_utils | |
| 62 | |
| 63 #endif // #ifndef CHROME_COMMON_GFX_COLOR_UTILS_H__ | |
| OLD | NEW |