Android - draw bitmap

My test Android app has a single activity, LoadImage, with two methods: an onCreate method that processes images with OpenCV, and a Display method which displays the image on the screen for 5 seconds. Here is what I have so far for the Display method:

[convert OpenCV matrix to a bitmap using an OpenCV method]

Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(bitmap, 0, 0, null);

try {
    synchronized (this) {
} catch (InterruptedException e) {

and here is the XML file for the single activity (it's a blank screen):

<RelativeLayout xmlns:android=""
    android:layout_height="match_parent" >

If I run the code as-is, I get... a blank screen. How do I get the bitmaps to show up?

Thanks so much.


Try this:

<RelativeLayout xmlns:android=""
    android:layout_height="match_parent" >


And do this in your java code:

    ImageView imageView = (ImageView) findViewById(;

You are sending the bitmap to the canvas right?

So do this there in your method where you are drawing into the bitmap.


You can not set the canvas directly to the imageView1.

Because as you know in real life, the canvas is just a brush. In the same way here also the canvas is only a brush. so dont worry about it.your edited image is now stored in the bitmap only. So thats why you can directly set the bitmap after editng by canvas.

Need Your Help

Android, How to get redirection event in WebView?

android url redirect webview

I my application I have an activity which includes a web view. When I request to open a connection server redirects me but my web view never get it and shows page not found message. When i test URL...

Base 64 Encoding Losing data

c++ encoding base64 encode encoder

This is my fourth attempt at doing base64 encoding. My first tries work but it isn't standard. It's also extremely slow!!! I used vectors and push_back and erase a lot.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.