Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

#Actualtom_mai78101

Posted 24 September 2012 - 06:13 AM

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]

#1tom_mai78101

Posted 24 September 2012 - 06:11 AM

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.preScale(-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]

PARTNERS