Re: [Vala] Vala to Android - Cairo



OK, I'm posting it mostly for the record, please note it is a long mail. Feel free to ask questions. Here we go. I found some pre-compiled versions of Cairo for Android on the Internet ; none of them was complete (with dependencies) nor usable with agcc/valac. So, after struggling a bit...
Cairo 1.10.2 for Android :
http://www.tarnyko.net/repo/cairo-1.10.2-android-(TARNYKO).tar.bz2
Here is a stand-alone Vala sample :
http://www.tarnyko.net/repo/cairo.vala
to be compiled with :
valac --cc=agcc --pkg cairo -o cairo cairo.vala --Xcc="-lpixman-1" --Xcc="-lpng15" It blits a "image.png" file with some overlay text. Should run fine on an Android phone.
Next step is to display this stuff to Android's screen, and here we have
a problem ; by design, the OS doesn't allow native code to draw to screen.
Any data should be passed between a native library (*.so) and a running Java app. So I will use AndroidBitmapInfo from JNI as a vector.
I've prepared a demo project :
http://www.tarnyko.net/repo/cairo-android-vala.tar.bz2
contains :
android.vapi : Android VAPI (dummy)
cairo-android.vala : Vala source
cairo-android.glue.c : C Android Glue
should be compiled with :
valac --cc=agcc -X -shared --pkg cairo --pkg android --vapidir . cairo-android.vala cairo-android.glue.c -o libcairo-android.so --Xcc="-lpixman-1" --Xcc="-lpng15" --Xcc="-ljnigraphics" and drops a "libcairo-android.so" file which you can call from Java :
static { System.loadLibrary("cairo-android"); }
drawPNG(bmp);
Regards,
Tarnyko


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]