Does anyone know of good documentation for the Skia drawing library used by Android?
The main Canvas object has hardly any state, so I'm thinking especially of the objects you can embed into the Paint object. I've worked out by trial and error how to use some ColorFilters and made a cool effect with ColorMatrixColorFilter. Now I have the drop shadows I want from the LinearGradient shader also. I think I understand PathEffects and have some ideas about XferModes. MaskFilters and Rasterizers are still utterly opaque to me. But trial and error is not a good way to understand a complicated library.
Mostly I'm concerned that the Android docs don't discuss 2d graphics and the means of using them at all. Even the class javadocs often don't explain what the class is doing. The actual function is all in Skia C code, which I can get, but it also lacks documentation. I've seen some cool demos but Google explained little about how they were done.
Is the only way to understand these things experimentation and reading the C code? What about efficiency and best practices? The Davlik/Android VM is sensitive to memory allocations and sometimes slow and I'm concerned that I'm not doing things the best way.
Skia has its own google code project site where you could find some high level overview.
Inline documents could be browse by this link in the project site
http://skia.googlecode.com/svn/trunk/docs/html/hierarchy.html
And you could join the discussion mail list. Designers and community will answer questions.
Another good reference is surprising from Apple. Apple QuickDraw GX documentations explained a lot of 2D vector graphics concepts and could apply to Skia well enough.
Android canvas API did have two difference implementation, one is Skia and another is OpenGL ES. The later implementation is so-called HWUI.
Regardless of the implementation, understanding the pipeline underlying the draw process is critical to understand how to use the canvas API.
Below are the best doc available so far describing the pipeline. You will definitely find it useful.
http://www.xenomachina.com/2011/05/androids-2d-canvas-rendering-pipeline.html
Related
After doing android programming for over a year, I think it's time to notch up things a little bit and what is a better way than OpenGl.
I would like to know which version of OpenGL ES should I learn, as I am a complete beginner.
I just started to learn Open GLES on Android (with no experience of Open GL before). I wasn't that interested in learning Open GLES, just getting my graphics to work (to set up a coordinate system and to draw images on it).
I read that it would be easier to learn GLES10 than to learn GLES20, so I went with GLES10. However, drawing an image in Open GL turned out to be a much more complex operation than I expected, and I thought that if I were going to learn all this, I might just as well learn GLES20, so I changed to that instead.
There aren't that many simple tutorials showing you how to draw images in Open GLES. Android's tutorial is quite bad. The code they show on the page is not the same as the code in the "Download the sample" link, the author of the tutorial seem to have made some mistakes, and it doesn't show you how to draw an image. Instead I would recommend this tutorial, although it's not as good as what I was looking for.
I know that my text doesn't answer your question, but I'm just sharing my thoughts in case you find them useful.
Your question should be closed since the answer to it would be completely subjective. Where it comes to the ES version there is no "better", only "better for your needs". I suggest you pick either ES1 or ES2.
There is a huge difference between the ES1 and the ES2 where the ES1 is still using a fixed pipeline and the ES2 is not. What that means is you will have to learn shaders in order to use ES2 and a lot of very handy tools such as a matrix stack are removed in ES2 due to the shaders. There are other libraries replacing those functionality but you still do need to understand them a bit more then in fixed pipeline.
So the ES1 is probably much easier for a beginner since you can have a nice drawing in a very short time but you will want to migrate to higher versions as quick as possible at which point most of the ES1 stuff will be useless to you. The ES2 can be a real pain to begin with and once you understand how things work you have quite a lot of power working with it, still that might take quite some time.
Also most of the current topics considering the openGL and the Android are targeting the ES2 version which means you will have most updated sources around the web.
Still in the end the choice is yours. I know I have not given you the answer but still I hope this helps you understand a bit what you are working with.
A New Year's resolution for me is to learn both the HTML5 Canvas and the Android Canvas API. (I do a lot of Swing scientific graphics stuff and need to branch out) How similar are they in concept and execution? Are they similar enough that is makes sense to try to learn both together at the same time? Or are they really different and I should probably focus on one at a time to avoid confusion?
I've used Swing's Graphics, HTML5's Canvas and Android's Canvas extensively and they are very similar. If you know how to use one of them, you'll quickly learn how to use the other two. The concepts are pretty much the same. The biggest difference is how Android stores some of the graphics state (it uses a Paint object you pass to the draw functions instead of setting the state directly on the Canvas.)
I would advise you to focus on one of them first, just to make things a bit easier.
I can tell you this...
They are of course similar, the most obvious difference being that HTML5 Canvas is designed to be cross platform where as Android Canvas is highly specialized, proprietary even. But just to get down to it..
HTML5 Canvas is web/server based and uses web language javascript to draw on the canvas.
Android is javascript and relatively the same.
I've been working with HTML5 Canvas and its very flexible and powerful. Im enjoying the color rendering system, with my experience the color normalization across systems helps a lot (especially with color sensitive charts). I've been experimenting with text animations and particle effects lately and I think its great for small screen applications! The easy of physics also makes it a great choice for more advanced implementations. Good Cross compatibility for my app/web hybrid apps (SaaS/SaP/B2B solutions)
HTML5 is young so its not without its problems, but I think with a properly coded website & SaaS/SaP/B2B Application any desired result is achievable. But there is plenty of information on stack about issues with loading HTML5 Canvas on Android phones & etc.
I read somewhere else on stack that PhoneGap might be a solution for you.
Here is a great chart that could help you: Mobile Frameworks
Hope this helps you!
I am embarking on a project (game) and I have a question about the implementation, will be developed specifically for Android and want to know which is better (easier, faster to develop and portable). canvas or OpenGL ES
Unless you already have a good working knowledge of OpenGL, then using a Canvas will be easier and faster. In terms of portability it really isn't as clear cut.
That said you should probably consider using one the pre-existing game engines, if you really only about Android then you should check out http://www.andengine.org/ its a great engine with a strong community and lots of great little example games.
Actually I'm not really sure where I read this,but when it's about developing game if you have any knowledge of OpenGL, you better use that,because the system is separating more space for your application so it can run without lagging or crash.So you can't get an Memory Full error. (Please correct me if I'm wrong.)
I want to achieve a nice 3D page curl animation in Android. I read some articles and found that nice effect can be achieved by OpenGL-ES so I started to learn OpenGL-ES (I did some of tutorials of OpenGL-ES and am still continuing) but I found it too complex for me to achieve this functionality. Also I got some examples which are available on StackOverflow and on the net, they work but I am not able to understand it, can someone guide me to achieve this functionality?
Based on the question comments I have an answer to this question.
YES, you can do that with OpenGL, BUT you need a deep understanding of math and graphics. This is a lot to learn, this will cost you at least a couple of weeks and it's definitely a hard path to go if you do it only because of this single animation (all of this applies if you don't take code which you probably won't understand and another human being put his whole effort into).
Nevertheless there might a ready to use implementation but unfortunately I can't present you one because I don't know if there's any out there.
Update
You callenged me, so I was eger to know whether there is something out there (because I saw that before and couldn't believe that there isn't a project out there which already does that for you).
And actually I found this question which seems to address the very same issue. And yes, there's someone who published his results here. And I have to admit: I looks awesome. It's also a pure java implementation.
But still: Having some background knowledge about OpenGL would enhance your whole attitude as developer. I'm not saying it's a must because not every one will succeed in OpenGL programming because it's quite hard to learn and implies a lot of math. But I think it's worth it because you will gain some deep understanding of current and all future graphical interfaces.
I'm new to Android and Java programming and I've manage to create a simple paint program, but how do I add a zoom feature? Right now I'm just extending the View class and using the "onDraw()" method.
Do I have to use a Drawable to be able to add zooming functionality? I'm not really understanding the differences between the two.
If I am way off base then please point me to a good tutorial on paint/zooming.
I think your question is beyond the scope that stackoverflow Q/A format can provide. I know you're asking for 'simple' but imho that's probably due to your lack of perception about the scope of the question that you're asking.
In order to support zooming you need to know what kind of image processing engine you want. Are you creating a vector or raster based drawing program? If you do not understand the difference between the two then you'll going to have a difficult time figuring out what to do.
You should probably at least gain a basic understanding about these various topics (links to books pulled more or less from the top of amazon's search results):
Image Processing
Computer Graphics Fundamentals, two, and three
SVG (vector graphic format)
Wikipedia links:
Vector Graphics
Raster Graphics
Image Processing
Open source image processing apps (not android but source code never hurts to see how others have done something)
Paint.net
GIMP
Inkscape
I'm sorry there isn't an easy and direct answer to your question. I'm also not saying that you need to become an expert in these topics to do what you want. You just need to familiarize yourself with them and then you'll probably be able to implement what you want without much difficulty.