我嘗試concatenize圖像塊爲一個帆布帆布只顯示黑屏
這裏是我的代碼
Canvas createCanvas(Bitmap[][] array){
int height = array[0][0].getHeight();
int width = array[0][0].getWidth();
Bitmap bitmap = Bitmap.createBitmap(3*height,3*width,Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap (array[0][0],0f,0f,new Paint(Paint.ANTI_ALIAS_FLAG));
canvas.drawBitmap (array[0][1],width,0f,new Paint(Paint.FILTER_BITMAP_FLAG));
//etc..etc..for all the tiles
return canvas;
}
調用此方法是這樣的:
//source File
Bitmap bMap = BitmapFactory.decodeResource(getResources(),R.drawable.image);
//Tile Source File
Bitmap [][] array_ref = helper_ref.createImageArrays(bMap);
//Invoke Method above
Canvas canvas = helper_ref.createCanvas(array_ref);
//Draw canvas
ImageView view_ref = (ImageView) findViewById(R.id.imageView1);
view_ref.draw(canvas);
我還爲你提供了我想畫的視圖。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
我認爲問題在於你爲canvas.drawBitmap中的最後一個參數傳遞null。嘗試傳遞一個繪畫對象。 – m1ntf4n 2012-02-22 16:39:58
嗯它沒有工作,但它是一個線索。我傳入了一個默認的Object new Paint()。也許是錯的? – dan 2012-02-22 16:45:05
我嘗試了2個Paint Constants沒有成功,我認爲不是這樣。我也爲你提供我畫的視圖。 – dan 2012-02-22 16:50:29