2010-05-25 62 views

回答

1

將圖像加載到框架中。
使用圖像左上角的鼠標座標。

假設您的圖像加載到BufferedImage,您可以使用:

int x,y; //populated from Mouse coordinates 
int rgb = myBufferedImage.getPixel(x,y); 

//to extract colors  
int red = (rgb & 0x00ff0000) >> 16; 
int green = (rgb & 0x0000ff00) >> 8; 
int blue = rgb & 0x000000ff; 

// and to create a new Java color 
Color c = new Color(red,blue,green); 
+0

非常感謝你:) – Adomas 2010-05-25 12:55:00