我正在开发第二个屏幕的任务栏(类似于displayfusion).
但是,我很难从图标中获得正确的平均颜色.例如Google Chrome /当我将其悬停在主任务栏上时,它背景会变黄.我的代码变成橙色/红色.
这就是它现在的样子:

如何获得正确的显性/平均颜色?
我用这段代码来计算平均颜色:
public static Color getDominantColor(Bitmap bmp)
{
//Used for tally
int r = 0;
int g = 0;
int b = 0;
int total = 0;
for (int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
Color clr = bmp.GetPixel(x, y);
r += clr.R;
g += clr.G;
b += clr.B;
total++;
}
}
//Calculate average
r /= total;
g /= total;
b /= total; …Run Code Online (Sandbox Code Playgroud)