Java examples for 2D Graphics:BufferedImage Color
Gets the color of a specific pixel in an image BufferedImage.
//package com.java2s; import java.awt.Color; import java.awt.image.BufferedImage; public class Main { /**/*from w w w . j av a 2 s . c om*/ * Gets the color of a specific pixel in an image. * * @param image * @return */ public static Color getPixelColor(BufferedImage image, int x, int y) { int pixel = image.getRGB(x, y); int red = (pixel & 0x00ff0000) >> 16; int green = (pixel & 0x0000ff00) >> 8; int blue = pixel & 0x000000ff; return new Color(red, green, blue); } }