|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Copyright (C) 2005-2012 XELOG AG
|
|
|
|
|
|
*/
|
|
|
|
|
|
package ch.spherIC.recurvebowsight;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
|
|
import android.graphics.BitmapFactory;
|
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @author FC Smilari
|
|
|
|
|
|
*/
|
|
|
|
|
|
public class PlatformUtils {
|
|
|
|
|
|
|
|
|
|
|
|
public static int platformSelectionColor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static int getPlatformSelectionColor(final Context ctx) {
|
|
|
|
|
|
|
|
|
|
|
|
Bitmap bitmap = BitmapFactory.decodeResource(ctx.getResources(), android.R.drawable.list_selector_background);
|
|
|
|
|
|
|
|
|
|
|
|
int redBucket = 0;
|
|
|
|
|
|
int greenBucket = 0;
|
|
|
|
|
|
int blueBucket = 0;
|
|
|
|
|
|
int pixelCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (bitmap != null) {
|
|
|
|
|
|
for (int y = 0; y < bitmap.getHeight(); y++) {
|
|
|
|
|
|
for (int x = 0; x < bitmap.getWidth(); x++) {
|
|
|
|
|
|
int c = bitmap.getPixel(x, y);
|
|
|
|
|
|
|
|
|
|
|
|
pixelCount++;
|
|
|
|
|
|
redBucket += Color.red(c);
|
|
|
|
|
|
greenBucket += Color.green(c);
|
|
|
|
|
|
blueBucket += Color.blue(c);
|
|
|
|
|
|
// does alpha matter?
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
platformSelectionColor = Color.rgb(redBucket / pixelCount, greenBucket / pixelCount, blueBucket / pixelCount);
|
|
|
|
|
|
return platformSelectionColor;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|