我正在向我的画布绘制带有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 :(得分:0)
在这里阅读绘图: http://developer.android.com/reference/android/view/View.html
答案 1 :(得分:0)
只是一个猜测:
而不是“Bitmap bmp = BitmapFactory.decodeFile(myfile.getPath()); “try”Bitmap bmp = BitmapFactory.decodeStream(..);“