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. AccountManager Authenticator only runs once per emulator restart.

I have written a simple Authenticator service to work with the new
AccountManager API introduced in 2.0.  When I launch a test app that
uses the authenticator the authenticator service is launched (as
expected) and it's onBind method is called.  However, if I run my test
application a second time in the same emulator (without restarting the
emulator) my service is not launched and onBind is not called.

So far the only way I have found to get my service to launch and
onBind to call again is to restart the emulator, which is a very time
consuming process.  I have looked at the Devices view in Eclipse and
ensured that all of my processes have been killed, just in case one of
them was just being rebound to or something.

-- 

2. How do I debug another application / service?

I am trying to write an Authenticator that works with the new
AccountManagement system.  When my application runs the system will
eventually spawn a process for the authenticator service that I
wrote.  I would like to be able to debug that service, but since it's
not part of the application currently being debugged the de{*filter*}
isn't attached to it by default.  I would like to have the de{*filter*}
attach to the service as soon as soon as it is spawned so I can step
through the startup process.

I am aware that I can just put Log.d(...) between every line of
code... but that seems very far from optimal for debugging.

-- 

3. Page Cycler test flakiness on Android

4. Error Eclair for ADP1 compilation

5. Warning when using BufferedInputStream

6. is it possble to covert .apk file iPhone compatibale device file

7. Create a BKS keystore file for SSL support of web server and handshake process