2009-09-10 5 views

답변

0

사용 비트 연산 - 교대와 마스크 :

int rgb = 0x123456; 

int red = (rgb >>> 16) & 0xff; 
int green = (rgb >>> 8) & 0xff; 
int blue = (rgb >>> 0) & 0xff; 

(분명히 오른쪽 시프트 - 바이 - 0 무관하다, 그러나 잘 일치합니다.)

이미이없는 경우 정수로 RGB 값, 귀하의 질문에 자세한 내용을주십시오.

2

당신의 질문이 무엇인지 분명하지 않다, 그러나 가정 색상은 문자열, 그때 당신이 할 수 있다고 생각 : 육각 인 경우 다음

String color = "#12FFFF"; 
int rgb = Integer.decode(color); 
Color c = new Color(rgb); 
int red = c.getRed(); 
int green = c.getGreen(); 
int blue = c.getBlue(); 

Color

0
int rgb = 0x123456; 

Color c = new Color(rgb); 
int red = c.getRed(); 
int blue = c.getBlue(); 
int green = c.getGreen(); 

에 대한 문서입니다 String에서 Long을 먼저 만들고 intValue()를 사용하여 색상을 만들어야합니다.