Very slow updating of screen

Problems with Canvas, OpenGL, etc...

Very slow updating of screen

Postby qute » Sun Jun 13, 2010 10:00 pm

Hi

I'm new to this android development.
I've read a lot on the net how to do it, but I can't get the speed I want/expect.

Code: Select all
In init:
bitmap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_8888);

my onDraw method:
   protected void onDraw(Canvas canvas) {
      // canvas.drawColor(0xFFCCCCCC); //if you want another background color

      makeLines();
      eval();
      for (int j = 0; j < HEIGHT-2; j++) {
         int heat = 0;
         for (int i = 0; i < WIDTH; i++) {
            heat = firebuf[j][i];
            bitmap.setPixel(i, j, palbuf[heat]);
         }
      }

      canvas.drawBitmap(bitmap, 0, 0, null);

      // refresh the canvas
      invalidate();
   }



Is this the way to do it?
I come from the PC world, where I would have 2 buffers directly to the gfx card. Write in one while the other is shown and then switch.
Couldn't find out how to do it on the android.
Attachments
balls.zip
(86.06 KiB) Downloaded 99 times
qute
Freshman
Freshman
 
Posts: 2
Joined: Sun Jun 13, 2010 9:49 pm

Top

Re: Very slow updating of screen

Postby qute » Sat Jun 19, 2010 1:06 pm

no help?
qute
Freshman
Freshman
 
Posts: 2
Joined: Sun Jun 13, 2010 9:49 pm

Re: Very slow updating of screen

Postby impi » Sat Jun 19, 2010 3:01 pm

setPixel and getPixel are very slow, because of the JNI overhead. Try using an array for your direct pixel manipulation and then use bitmap.setPixels(array,...)

This should speed up the thing, if this is not enough, go native code.
impi
Developer
Developer
 
Posts: 29
Joined: Wed Apr 28, 2010 11:17 pm

Re: Very slow updating of screen

Postby kevinsimpson35 » Tue Apr 17, 2012 8:58 am

Nice question. there is so much to learn in Android that it is almost difficult to get everything in your head.
kevinsimpson35
Freshman
Freshman
 
Posts: 3
Joined: Thu Apr 12, 2012 8:38 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 1 guest