2017-09-19 5 views
0

난 크기, 내 당김-xhdpi 폴더에 자사의 32 × 32 픽셀을 내가 PNG 이미지가 : 나 이미지를 생성 할 때안드로이드 비트 맵 색 혼란

enter image description here 내가 정확히 두 개의 색상을 사용했다.

renderSystem.addSprite(R.drawable.walltest, 0, 2); 

rendersystem에서 :

public void addSprite(int id, int x, int y) { 
    Bitmap image = BitmapFactory.decodeResource(context.getResources(), id); 
    printColors(image); 
    //active.add(new Sprite(image, worldToScreenX(x), worldToScreenY(y))); 
} 


private void printColors(Bitmap src) { 
    for (int i = 0; i < src.getWidth(); i++) { 
     for (int j = 0; j < src.getHeight(); j ++) { 
      Log.d("Color", String.valueOf(src.getPixel(i,j))); 
     } 
    } 
} 

난, 비트 맵으로 이미지를로드 루프 쓰루를 내가 두 개 이상의 서로 다른 색의 값을 참조 로그 캣 각 컬러 값을 출력

출력 :

09-19 13:03:38.832 2576-2576/com.example.benjamin.dungeondweller I/chatty: uid=10082(u0_a82) com.example.benjamin.dungeondweller identical 36 lines 
09-19 13:03:38.832 2576-2576/com.example.benjamin.dungeondweller D/Color: -7975603 
09-19 13:03:38.832 2576-2576/com.example.benjamin.dungeondweller D/Color: -10734540 
09-19 13:03:38.832 2576-2576/com.example.benjamin.dungeondweller D/Color: -16777216 
09-19 13:03:38.832 2576-2576/com.example.benjamin.dungeondweller D/Color: -16777216 
09-19 13:03:38.832 2576-2576/com.example.benjamin.dungeondweller D/Color: -11325392 
09-19 13:03:38.832 2576-2576/com.example.benjamin.dungeondweller D/Color: -7975603 
09-19 13:03:38.832 2576-2576/com.example.benjamin.dungeondweller I/chatty: uid=10082(u0_a82) com.example.benjamin.dungeondweller identical 8 lines 
09-19 13:03:38.832 2576-2576/com.example.benjamin.dungeondweller D/Color: -7975603 
09-19 13:03:38.851 2576-2576/com.example.benjamin.dungeondweller D/Color: -10734540 
09-19 13:03:38.857 2576-2576/com.example.benjamin.dungeondweller I/chatty: uid=10082(u0_a82) com.example.benjamin.dungeondweller identical 9 lines 
09-19 13:03:38.857 2576-2576/com.example.benjamin.dungeondweller D/Color: -10734540 
09-19 13:03:38.857 2576-2576/com.example.benjamin.dungeondweller D/Color: -12639196 
09-19 13:03:38.857 2576-2576/com.example.benjamin.dungeondweller D/Color: -16777216 
09-19 13:03:38.860 2576-2576/com.example.benjamin.dungeondweller I/chatty: uid=10082(u0_a82) com.example.benjamin.dungeondweller identical 41 lines 
09-19 13:03:38.860 2576-2576/com.example.benjamin.dungeondweller D/Color: -16777216 

이것은 비트 맵 이미지에 같은 색상이 없음을 나타냅니다. 소스 PNG 이미지로. 왜 그런가요? 그리고 비트 맵 형식으로 정확한 복제본을 어떻게로드합니까?

답변

0

작성하는 동안 비트 맵이 필터링 되었기 때문입니다. 픽셀의 개별 RGB 값을 확인하고 약간의 차이점을 확인하십시오.

+0

필터링을 어떻게 비활성화합니까? –

+0

Nevermind, 나는 bitmapfactory 옵션을 만들고 inscaled를 true로 설정했습니다. 이제 작동합니다. –

+0

괜찮습니다. –