我的测试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