我的測試Android應用程序有一個活動,LoadImage,有兩種方法:一個onCreate方法處理圖像與OpenCV,和一個顯示方法,在屏幕上顯示圖像5秒。以下是我迄今爲止的顯示方法:Android - 繪製位圖
[convert OpenCV matrix to a bitmap using an OpenCV method]
Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(bitmap, 0, 0, null);
try {
synchronized (this) {
wait(5000);
}
} catch (InterruptedException e) {
}
這裏是爲單一活動的XML文件(這是一個空白屏幕):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
如果我運行代碼原樣是,我得到了...一個空白的屏幕。我如何讓位圖顯示出來?
非常感謝。
創建一個'ImageView',將它的源代碼設置爲你的'Bitmap',然後將它添加到你的'RelativeLayout'中? – Eric