I think the easiest way to do such a conversion on Android is to use OpenGL. You can treat the bitmap as a texture. You can then use the detected angles as texture coordinates. Assign each of them as a texture coordinate to the corresponding vertex of a simple rectangular shape. Then ask OpenGL to draw it on your canvas. Pseudocode:
glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, pictureId); glBegin(GL_QUAD); glVertex(0,0); // left upper corner glTexCoord(corners[0].x/picture.getWidth(), corners[0].y/picture.getHeight()); glVertex(1,0); // right upper corner glTexCoord(corners[1].x/picture.getWidth(), corners[1].y/picture.getHeight()); glVertex(1,1); // right lower corner glTexCoord(corners[2].x/picture.getWidth(), corners[2].y/picture.getHeight()); glVertex(0,1); // left lower corner glTexCoord(corners[3].x/picture.getWidth(), corners[3].y/picture.getHeight()); glEnd();
You do not need a camera or complex conversions. Of course, this is not very convenient, since using OpenGL for such a simple task is an unnecessary question. But there really is no simpler way than to write such texturing yourself. If you want, you can start reading from the wiki and go to external links and see, for example, the software implementation of texturing methods:
http://en.wikipedia.org/wiki/Texture_mapping
You can also try using any of the OpenGL effect representations, this will simplify the setup, but also ask you to create a shader or two:
http://code.google.com/p/effect-view/
source share