Here you can find the source of RgbToGray(int r, int g, int b)
public static int RgbToGray(int r, int g, int b)
//package com.java2s; /*/* ww w .j av a 2 s . com*/ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ public class Main { public static int RgbToGray(int r, int g, int b) { return (int) (r * .3 + g * .59 + b * .11); } public static int RgbToGray(int xrgb) { return RgbToGray((xrgb >> 16) & 0xff, (xrgb >> 8) & 0xff, (xrgb) & 0xff); } }