Bitmap is not on canvas after drawing
I am drawing a Bitmap with canvas.drawBitmap(bmp, 0, 0, null);
to my canvas and the bitmap will just not show. Any ideas?
Thank you!
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, 开发者_C百科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");
Can you draw a line? Either call invalidate() or postInvalidate().
Read Drawing here: http://developer.android.com/reference/android/view/View.html
And copy some examples like: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.html
Just a guess:
Instead of "Bitmap bmp = BitmapFactory.decodeFile(myfile.getPath()); " try "Bitmap bmp = BitmapFactory.decodeStream(..);"
精彩评论