It seems one again I have answered my own question. I still dont
understand how drawBitmapMesh works but I can achieve what I want to
by using the Camera object. The Camera object allows you to rotate 2D
objects in 3D space. The following code snippet (very much test code)
demonstrates what is required.

-------------------------------------------------------------------

@Override
protected void dispatchDraw(Canvas canvas)
{
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.grid_bitmap);

        final int viewWidth = this.getWidth();
        final int viewHeight = this.getHeight();

        final int bitmapWidth = bitmap.getScaledWidth(canvas);
        final int bitmapHeight = bitmap.getScaledHeight(canvas);

        float scaleX = viewWidth / (float) bitmapWidth;
        float scaleY = viewHeight / (float) bitmapHeight;

        int preCenterX = bitmapWidth / 2;
        int preCenterY = bitmapHeight / 2;
        int postCenterX = viewWidth / 2;
        int postCenterY = viewHeight / 2;

        Paint mPaint = new Paint();
        mPaint.setAntiAlias(true);
        mPaint.setFilterBitmap(true);

        Camera mCamera = new Camera();
        mCamera.save();

        // Here is the rotation in 3D space
        mCamera.rotateY(30);

        Matrix mMatrix = new Matrix();
        mCamera.getMatrix(mMatrix);
        mCamera.restore();
        mMatrix.preTranslate(-preCenterX, -preCenterY);
        mMatrix.postScale(scaleX, scaleY);
        mMatrix.postTranslate(postCenterX, postCenterY);

        canvas.drawBitmap(bitmap, mMatrix, mPaint);
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to