Java tutorial
//package com.java2s; import android.graphics.ColorMatrix; import android.graphics.ColorMatrixColorFilter; import android.graphics.Paint; public class Main { /** * * @param paint */ public static void setThreshold(Paint paint, float threshold) { /* * Elevation matrix. This will threshold the elevation with GPS altitude. * The factor is used to increase the brightness for a given elevation map. * Elevation map is prepared so that altitudes from 0-5000 meter are encoded with 0-200 pixel values. * Each pixel level is 25 meter. * * Negative sign for black threshold instead of white. * Threshold of to 0 to 100 translated to 0 - 200 for all pixels thresholded at 5000 meters. * * Calibrated (visually) at * KRNO - 1346 meters, threshold = 28 * KLXV - 3027 meters, threshold = 61 * L70 - 811 meters, threshold = 16 * KHIE - 326 meters, threshold = 7 *-------------------------------------------- * 5510 = 112 ~ 50 meters per px * Formula to calculate threshold is: * threshold = altitude / 3 (meters per foot) / 50 * Give 2 levels margin of safety */ float factor = 4.f; float mx[] = { factor, 0, 0, 0, -(factor) * (threshold - 5) * 2.0f, 0, factor / 1.5f, 0, 0, -(factor) * (threshold - 5) * 2.0f, 0, 0, factor / 2.0f, 0, -(factor) * (threshold - 5) * 2.0f, 0, 0, 0, 1, 0 }; ColorMatrix cm = new ColorMatrix(mx); paint.setColorFilter(new ColorMatrixColorFilter(cm)); } }