2016-11-21 1 views
0

사용자가 스 와이프 할 때 비트 맵의 ​​일부를 음영 처리 할 수있는 응용 프로그램에서 작업 중입니다. 그런 다음 스 와이프가 끝나면 비트 맵의 ​​해당 부분을 잘라내어 일부 기능을 수행하는 메서드를 호출합니다. 그러나 자르기 비트 맵은 여기에 문제가 없으므로 어디에도 저장되지 않습니다. imageView를 클릭하면 원본 비트 맵으로 비트 맵을 다시 설정합니다. 비트 맵을 회전시키는 기능도 있습니다. 두 비트 맵 객체 bill (사용자가 실제로 스 와이프)과 billOrg (그대로 원래 비트 맵)가 있습니다. 방법은 다음과 같습니다. > 다음 회전 -비트 맵을 수정하는 중 Android 충돌이 발생합니다. jni_helper.cc:110 비트 맵의 ​​형식이 잘못되었습니다. 4

private void resetImageView(boolean saveShade){ 
     //the boolean var here tell whether to keep the shaded portion after reset or not 
     if(!saveShade) { //app crashes in this if block although I have try-catch. 
      try { 
       Canvas canvas = new Canvas(bill); 
       Log.e("resetImageView", "billOrg:" + billOrg.isMutable() + ",bill:" + bill.isMutable()); //returns true for both bitmap objects 
       canvas.drawBitmap(billOrg, 0, 0, null); 
       touchBounds = ""; 
       tv_res.setText(""); 
       rl.invalidate(); 
       setImage(bill); 
      }catch(Exception ex){ 
       Log.e("resetImage",ex.getMessage()); 
      } 
     }else{ 
      Canvas canvas = new Canvas(bill); 
      canvas.drawBitmap(bill, 0, 0, null); 
      touchBounds = ""; 
      tv_res.setText(""); 
      rl.invalidate(); 
      setImage(bill); 
     } 
    } 

모든 사용자는 먼저 이미지 와이프 때를 제외 괜찮 : 클릭시 맵 재설정

public void rotateImage(View v){ 
    TAG = "rotateImage"; 
    Matrix matrix = new Matrix(); 
    matrix.postRotate(90); 
    Bitmap rotatedBitmap = Bitmap.createBitmap(bill , 0, 0, bill.getWidth(), bill.getHeight(), matrix, true); 
    bill = rotatedBitmap.copy(rotatedBitmap.getConfig(),true); 
    createScaledBitmap(); 
    billOrg = bill.copy(rotatedBitmap.getConfig(),true);//bill.copy(bill.getConfig(),false); 
    setImage(bill); 

    rl.invalidate(); 
} 

방법 : 여기

private void drawShade(float left,float top,float right,float bottom){ 
    //this method draws shade on bitmap. Coordinates are sent from onTouchEvent 
    TAG = "drawShade"; 
    //parseTouchPointsString(); 
    Bitmap tempBitmap = Bitmap.createBitmap(bill.getWidth(), bill.getHeight(), Bitmap.Config.RGB_565); 
    Log.d(TAG,"bill:"+bill.isMutable()+"tempBit:"+tempBitmap.isMutable()+""); 
    Canvas tempCanvas = new Canvas(tempBitmap); 
    tempCanvas.drawBitmap(bill,0,0,null); 
    tempCanvas.drawRoundRect(new RectF(left,top,right,bottom), 10, 10, shadePaint); 
    imgView.setImageDrawable(new BitmapDrawable(getResources(), tempBitmap)); 
    if(fingerUp) { 
     Log.e("fingerUp",fingerUp+""); 
     bill = tempBitmap; 
    } 
    Log.d(TAG,"shade drawn at:"+left+","+top+","+right+","+bottom); 
} 

비트 맵 회전 방법 이미지 -> 비트 맵을 클릭합니다. 이 오류는 jni_helper.cc:110입니다. 비트 맵의 ​​형식이 잘못되었습니다 : 4. 다른 예외는 없습니다. 내 지식에 따라 비트 맵 개체를 수정하려고하면 비트 맵에서 오류가 발생하지만 모든 위치에서 변경할 수 있습니다. 또한 로그에 변경 가능을 인쇄합니다. 비트 맵을 수정하는 중에 뭔가 잘못하고있는 것 같아요. 나는 너를 혼란스럽게 할지도 모른다. 나는 내가 얼마나 잘 설명했는지 모른다. 어떤 명확성이 필요하면 친절하게 물어보십시오. 나는 도움이 필요해.

답변

0

좋아, 그래서 문제를 일으키는 것을 발견했다.

Bitmap tempBitmap = Bitmap.createBitmap(bill.getWidth(), bill.getHeight(), Bitmap.Config.RGB_565); 

drawShade() 메소드가 범인입니다. "Bitmap.Config.RGB_565"를 bill.getConfig()로 변경하여 수정되었습니다.

관련 문제