2012-09-01 7 views
2

인덱스 이미지 (png8 또는 gif)의 이미지 데이터 (팔레트 인덱스 배열)에 액세스하려면 어떻게합니까?인덱스 이미지의 데이터 (팔레트 인덱스) 얻기

예 :

  • 이미지 팔레트 : {0xFF0000이고, 0x00FF00, 0x0000FF 등}
  • 이미지 데이터 : {01101222010 , 2,0,1,1,0}

어떤 I 필요한 것은 :

ArrayList<Integer> getImageData(File image) { 
    /* ??? */ 
} 
+0

은 BTW :' ArrayList를'잘못된 것입니다. 일반 클래스는 참조 유형으로 입력해야하며 기본 유형이 아니어야합니다. 당신은 복싱 클래스'Integer' ->'ArrayList '을 사용해야합니다. – halex

+0

고맙습니다. 고맙습니다. – Aoshi

답변

0

코드 아래 imageData로 화상 데이터를 읽어,배열값.

BufferedImage image = ImageIO.read(imageFile); 
    int width = image.getWidth(); 
    int height = image.getHeight(); 
    int[] imageData = new int[width * height * image.getColorModel().getNumComponents()]; 
    imageData = image.getData().getPixels(0, 0, width, height, imageData); 
+0

고마워요,이게 내가 찾고있는 것입니다. – Aoshi