Here you can find the source of invertColor(int color)
Parameter | Description |
---|---|
color | a parameter |
public static int invertColor(int color)
//package com.java2s; /**/*w w w. ja va 2 s . co m*/ * Get a short description of the licensing terms. */ import java.awt.Color; public class Main { /** * Inverts color parsed as integer * * @param color * @return inverted color as integer * @see java.awt.Color */ public static int invertColor(int color) { Color origColor = new Color(color); /* * color's integer has format: * red: bits 16-23 * green: bits 8-15 * blue: bits 0-7 * * so we need to invert the individual components (R,G,B) * and put them to their decade */ int invertedRed = ((255 - origColor.getRed()) * 65536); int invertedGreen = ((255 - origColor.getGreen()) * 256); int invertedBlue = ((255 - origColor.getBlue())); return invertedRed + invertedGreen + invertedBlue; } }