2010-05-25 23 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

相关问题