2011-07-02 7 views
0

canvas.drawBitmap(bmp, 0, 0, null); 비트 맵을 내 캔버스에 그려야 비트 맵이 표시되지 않습니다. 어떤 아이디어?드로잉 후 비트 맵이 캔버스에 없습니다.

감사합니다.

  Bitmap bmp = BitmapFactory.decodeFile(myfile.getPath()); 
      //Bitmap bmp = BitmapFactory.decodeStream(bis); 

      Log.i(TAG, "builded Bitmap");    
      Log.i(TAG, "scaling bitmap..."); 


      //int scale; 
      //Matrix matrix = new Matrix(); 
      //matrix.setScale(0.1F, 0.1F); 
      //if (bmp.getWidth() < bmp.getHeight()){ 
      // scale = canvas.getWidth()/bmp.getWidth(); 
      //}else{ 
      // scale = canvas.getHeight()/bmp.getHeight(); 
      //} 
      //matrix.postScale(scale, scale, bmp.getWidth(), bmp.getHeight()); 
      //matrix.postScale(0.5F, canvas.getWidth()/bmp.getWidth()); 

      //Bitmap bmp2 = Bitmap.createScaledBitmap(bmp, canvas.getWidth(), canvas.getHeight(), true); 

      //Paint p = new Paint(); 
      //p.setFilterBitmap(true); 


      //try{ 
      bmp = Bitmap.createScaledBitmap(bmp, canvas.getWidth(), canvas.getHeight(), true); 
      Log.i(TAG, "scaled"); 
      Log.i(TAG, "showing bitmap..."); 
      canvas.drawBitmap(bmp, 0, 0, null); 
      Log.i(TAG, "showed bitmap"); 

답변

0

줄을 그릴 수 있습니까? invalidate() 또는 postInvalidate()를 호출하십시오. http://developer.android.com/reference/android/view/View.html

과 같은 몇 가지 예제를 복사 :

읽기 여기 그리기 http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.html

+0

비트 맵을 그려서 선을 그으면 작동합니다! 라이브 배경을 볼 수 없기 때문에 뷰에서 무효화를 호출 할 수 없습니다. – nomoral

0

그냥 추측 :

대신 "의

비트 맵 BMP = BitmapFactory.decodeFile (myfile.getPath()) ; "try"Bitmap bmp = BitmapFactory.decodeStream (..); "

+0

BitmapFactory.decodeFile은이 버그로 인해 해결 방법입니다 : http://code.google.com/p/android/issues/detail? id = 6066 – nomoral

+0

나는 그 사실을 몰랐습니다! 고맙습니다! – Chandan

관련 문제