GetSingleColor

This commit is contained in:
Mirek Fidler 2026-07-16 10:23:22 +02:00
parent af415061c9
commit b2744e1689
5 changed files with 615 additions and 598 deletions

View file

@ -349,6 +349,12 @@ Image Hot3(const Image& m)
return WithHotSpots(m, sz.cx / 3, sz.cy / 3, sz.cx - sz.cx / 3, sz.cy - sz.cy / 3);
}
Value ImageOrColor(const Image& m)
{
Color c = GetSingleColor(m);
return IsNull(c) ? (Value)m : (Value)c;
}
Image ChHot(const Image& m, int n)
{
return WithHotSpots(m, DPI(n), DPI(n), 0, 0);

View file

@ -40,6 +40,8 @@ Color GetInk(const Image& m); // the color that is most different from AvgColor
int GetRoundness(const Image& m);
void FixButton(Image& button); // fix button if it is too close to face color
Value ImageOrColor(const Image& m);
Image WithRect(Image m, int x, int y, int cx, int cy, Color c);
Image WithLeftLine(const Image& m, Color c, int w = DPI(1));
Image WithRightLine(const Image& m, Color c, int w = DPI(1));

File diff suppressed because it is too large Load diff

View file

@ -156,6 +156,14 @@ bool IsSingleColor(const Image& m, const Rect& rect_)
return true;
}
Color GetSingleColor(const Image& m)
{
Size sz = m.GetSize();
if(sz.cx == 0 || sz.cy == 0 || !IsSingleColor(m, sz))
return Null;
return m[0][0];
}
Image RecreateAlpha(const Image& overwhite, const Image& overblack)
{
Size sz = overwhite.GetSize();

View file

@ -139,6 +139,7 @@ Image HorzSymm(Image src);
double Difference(const Image& a, const Image& b);
bool IsSingleColor(const Image& m, const Rect& rect);
Color GetSingleColor(const Image& m);
Image RecreateAlpha(const Image& overwhite, const Image& overblack);
int ImageMargin(const Image& m, int p, int dist);