0
如何通過使用可寫位圖從Windows應用商店中的圖像獲取RGB顏色百分比。從圖像中獲取RGB顏色百分比
在Windows應用程序,我得到它前面是這樣的:
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;
return Color.FromArgb(r, g, b);
}
你怎麼可以在Metro應用可寫位做到這一點?