Original Post
Currently, I have created a simple SurfaceView that blits a bitmap onto the screen, like how Canvas does in Java. I'm currently playing around the Matrix variable, so that I can pass it to the Canvas.drawBitmap() as a parameter.
The matrix manipulation, something that is used prominently in bitmap blitting, is a bit difficult for me to grasp correctly. Especially at the point where the Matrix involves pre- or post- when doing calculations (preScale(), preSkew(), preTranslate(), etc., and postScale(), postSkew(), etc.)
I'm using the class "android.graphics.Matrix", and not the "android.opengl.Matrix", just to clarify.
[source lang="java"] Matrix matrix = new Matrix();
matrix.reset();[/source]
I think this initializes the matrix variable.
[source lang="java"]Canvas c = holder.lockCanvas();
c.drawRGB(128, 128, 120);
matrix.postScale(-1, 1);
c.drawBitmap(bitmap, matrix, null);
holder.unlockCanvasAndPost©;[/source]
After that, the bitmap itself does nothing. What am I doing wrong? Isn't it?:
[source lang="java"] 1 0 * [-1] = -1 0
0 1 [ 1] 0 1[/source]
The matrix manipulation, something that is used prominently in bitmap blitting, is a bit difficult for me to grasp correctly. Especially at the point where the Matrix involves pre- or post- when doing calculations (preScale(), preSkew(), preTranslate(), etc., and postScale(), postSkew(), etc.)
I'm using the class "android.graphics.Matrix", and not the "android.opengl.Matrix", just to clarify.
[source lang="java"] Matrix matrix = new Matrix();
matrix.reset();[/source]
I think this initializes the matrix variable.
[source lang="java"]Canvas c = holder.lockCanvas();
c.drawRGB(128, 128, 120);
matrix.postScale(-1, 1);
c.drawBitmap(bitmap, matrix, null);
holder.unlockCanvasAndPost©;[/source]
After that, the bitmap itself does nothing. What am I doing wrong? Isn't it?:
[source lang="java"] 1 0 * [-1] = -1 0
0 1 [ 1] 0 1[/source]