2014-06-06 4 views
0

여러 비트 맵, 행렬 및 페인트에 대해 arraylists를 만들었으므로 주 스레드에서 동적으로 변경하고 싶습니다. 내가 원하는 무엇Java Android - 그려진 후 비트 맵 회전

public DrawView(Context context, AttributeSet attrs){ 
     bitmapArray.add(bitmap1); 
     Matrix matrix2 = new Matrix(); 
     matrixArray.add(matrix2); 
     Paint paint = new Paint(); 
     paintArray.add(paint); 
} 

protected void onDraw(Canvas canvas) { 
    super.onDraw(canvas); 

    for (int i = 0; i < 50; i++) { 
     canvas.drawBitmap(bitmapArray.get(i), matrixArray.get(i), paintArray.get(i)); 
    } 
} 



public void translate(int Num, float x, float y){ 
    matrixArray.get(Num).postTranslate(x,y); 

} 

지금처럼 내 메인 스레드에서 drawview.translate를 호출하는 것입니다 : :

drawView.translate(Num, image.getX(), image.getY()); //image is a moving imageview 

것은 내가 찾을 수 없습니다 이것은 내 drawview (을 단축 할 몇 가지 코드를 잘라)입니다

: 사람이 내가 크게 감사하겠습니다 설명 할 수 그래서 만약 그려진 비트 맵을 제어하는 ​​메인 스레드를 사용하는 방법에 대해 많이

답변

0

나는 결국 내 비트 맵을 그리고/내 명령에 회전 이동하는 방법을 발견했습니다 내 O에서 nDraw() {

canvas.drawBitmap(bitmap1, null, rectf, sPaint); 

이동 가능한 rectF을 사용하고 회전 : 내 비트 맵을 회전 할 때이 문제가되었다

rotation = ((float) Math.toDegrees(Math.atan2((fingery - rectf.centerY()),(fingerx - rectf.centerX()))); 

     matrix.setRotate(rotation2+90, rectf.centerX(), rectf.centerY()); 
     bitmap1 = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); 

, 그것은 크기를 변경. 나는 다음을 사용하여 그것을 고쳤다 :

 rectf.right = rectf.centerX() + bitmap1.getWidth()/2; 
     rectf.left = rectf.centerX() - bitmap1.getWidth()/2; 
     rectf.top = rectf.centerY() - bitmap1.getHeight()/2; 
     rectf.bottom = rectf.centerY() + bitmap1.getHeight()/2; 

나는 이것이 어떤 사람들을 돕기를 희망한다!