Hi Max,
Yes, for painting bitmaps on the screen OpenGL doesn't perform too
well, so it is better to use the SurfaceView for doing the drawing. In
addition to that, the colorspace of the bitmap also plays an important
role. Based on my tests, RGB565 performed the best.
You can draw to the SurfaceView either through the Java (public API),
or either through the native space (private API).
The Java based drawing is very easy to accomplish, but if you would
like to do the native drawing, please do the following:
- Get the Android source code for (platform/frameworks/base.git) from
android.git.kernel.org.
- Implement the SurfaceHolder.Callback as usual in your Java
application.
- As soon as you have the Surface ready, pass it to the native code
through JNI.
- On the native code, do the following to get the native interface:
jclass surfaceClass = env->FindClass("android/view/Surface");
jfieldID fieldId = env->GetFieldID(surfaceClass, "mSurface", "I");
sp<Surface> surface = env->GetIntField(surface, fieldId);
- At this stage we have the Surface instance, so in order to draw your
bitmap, you can do the following:
SurfaceInfo info;
surface->lock(&info, true);
memcpy(info.bits, bitmapBytes, bitmapSize);
surface->unlockAndPost();
If you are planing to do the drawing on a native thread, please make
sure to attach it to the JVM also.
Again, this is not a part of the public API.
Regards,
-onur
---
www.zdo.com