Bitmap rotations with canvas

Problems with Canvas, OpenGL, etc...

Bitmap rotations with canvas

Postby Tec » Mon Oct 25, 2010 7:57 pm

Hi there.

I'm new to android, I'm just experimenting at the moment and I'm having difficulty with a particular issue, rotating a bitmap image. More more specifically I'm getting really odd results when either the degree value is anything but 90, or 180 which both work fine. If a different value is provided my bitmap spins off the screen and it becomes very blurry.

(This rotation is triggered when someone touches the screen)

Code: Select all
Example code I'm using is;

Matrix matrix = new Matrix();
      
matrix.setTranslate(this.xPos + (this.picture.getWidth() / 2), this.yPos + (this.picture.getHeight() / 2));
      
//Any value other than 90, or 180 causes the bitmap to spin off the screen and the bitmap becomes blurry.
matrix.postRotate(92, (this.xPos + this.picture.getWidth() / 2), (this.yPos + this.picture.getHeight() / 2));

this.picture = Bitmap.createBitmap(this.picture, 0, 0, this.picture.getWidth(), this.picture.getHeight(), matrix, true);


I'd be grateful for any assistance.

Many thanks,
Adam
Tec
Freshman
Freshman
 
Posts: 2
Joined: Mon Oct 25, 2010 6:55 pm

Top

Re: Bitmap rotations with canvas

Postby Schermvlieger » Mon Oct 25, 2010 8:06 pm

I don't have access to eclipse on this pc but are the x,y coordinates for postrotate not floats?
Schermvlieger
Senior Developer
Senior Developer
 
Posts: 159
Joined: Fri Feb 26, 2010 1:37 pm

Re: Bitmap rotations with canvas

Postby Tec » Mon Oct 25, 2010 9:30 pm

They are currently floats.
Tec
Freshman
Freshman
 
Posts: 2
Joined: Mon Oct 25, 2010 6:55 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 1 guest