Here you can find the source of invertColor(int color)
public static int invertColor(int color)
//package com.java2s; /**//from ww w . j a v a 2s.co m * Java * * Copyright 2014-2018 IS2T. All rights reserved. * * Use of this source code is subject to license terms. */ public class Main { private static final int RED_SHIFT = 16; private static final int GREEN_SHIFT = 8; private static final int BLUE_SHIFT = 0; private static final int RED_MASK = 0xff << RED_SHIFT; private static final int GREEN_MASK = 0xff << GREEN_SHIFT; private static final int BLUE_MASK = 0xff << BLUE_SHIFT; public static int invertColor(int color) { int red = getRed(color); int green = getGreen(color); int blue = getBlue(color); red = 0xff - red; green = 0xff - green; blue = 0xff - blue; return getColor(red, green, blue); } public static int getRed(int color) { return (color & RED_MASK) >>> RED_SHIFT; } public static int getGreen(int color) { return (color & GREEN_MASK) >>> GREEN_SHIFT; } public static int getBlue(int color) { return (color & BLUE_MASK) >>> BLUE_SHIFT; } public static int getColor(int red, int green, int blue) { return (red << RED_SHIFT) & RED_MASK | (green << GREEN_SHIFT) & GREEN_MASK | (blue << BLUE_SHIFT) & BLUE_MASK; } }