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