Java tutorial
//package com.java2s; public class Main { public static final int BLUE_SHIFT = 0; public static final int LED_INTENSITY_LEVEL_COUNT = 4; public static int color2LedBlue(int color) { int blue = (color >> BLUE_SHIFT) & 0xFF; int newBlue = (int) Math.round(blue * (LED_INTENSITY_LEVEL_COUNT - 1) / (double) 0xFF); return newBlue; } }