Total members 11895 |It is currently Sun Dec 22, 2024 6:52 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





hello

i've the code :

Code:
class A{
    public static void main(String[] args){
        try {
            BufferedImage bi=ImageIO.read(new File("C:\\a.gif"));
     int a=bi.getRGB(20,20);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
       
    }
}


i don't know how to get the color name , i can create new Object from color by Color(r,b,g) but i want the name .
and it seem hard because i must do bit twice (&00xFF)

is there any alternative ways to get Color name from specific pixel ?




Author:
Newbie
User avatar Posts: 17
Have thanks: 0 time

Hi ,Xline
Code:
int a=bi.getRGB(20,20);

now you can use the value of a to get the R ,G,B Components using binary Shift like Bellow

Code:
               int r = (rgb >> 16) & 0xff;
                    int g = (rgb >> 8) & 0xff;
                    int b = (rgb >> 0) & 0xff;

then you can use it in new Color(R,G,B);

and also you can get it Back to Original Value
Code:
    rgb= (rgb & 0xff000000) | (r << 16) | (g << 8) | (b << 0);



I Hope that helped you

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : how to get Color name from a specific pixel ??
 Specific Colors for Specific Forum     -  
 ban visitor from a specific IP-address     -  
 Reading a Specific Character in php     -  
 ordered list from specific number     -  
 Rotate Image with specific angle     -  
 Check the websites hosted at a specific IP     -  
 Clear specific form fields using JQuery     -  
 Slide automatically-specific speed to a determined position     -  
 Color and CSS     -  
 skymiles background color     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com