Fast screen update

by qute » Tue, 22 Jun 2010 04:27:07 GMT


Sponsored Links
 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.


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

my onDraw method:
protected void onDraw(Canvas canvas) {

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.

--



Fast screen update

by Miguel Morales » Tue, 22 Jun 2010 04:44:28 GMT


 Well, it looks like you're setting every pixel on the bitmap on every frame.
Android is not a PC, it's equivalent to a 10-15 year old pc, you'll
have to optimize your code.

You can try drawing directly to the canvas, instead of drawing to a
bitmap, and then drawing that bitmap onto the canvas.
Watch this:
 http://code.google.com/events/io/2009/sessions/WritingRealTimeGamesAndroid.html 
and then download things like this:
 http://code.google.com/p/apps-for-android/source/browse/trunk/ #trunk/SpriteMethodTest
and this to see how it's done in production:
 http://replicaisland.net/  (it's an open source 2d game)



>


Sponsored Links


Other Threads

1. tanya app

-- 
=========================
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group:

Click  

2. all in one poste for site visite all sites here''

--

3. Help with scrollbar in resized LinearLayout

4. Port x86 program to Android met error

5. Wrapping horizontal list view?

6. Reminder IRC office hours today 5:00- 6:00 PST

7. Any way to go from an itermId to position in a ListView/Adapter