dimanche 31 août 2014

Rotate around alternate axis


Vote count:

0




I am struggling with bitmap rotations. I wish to rotate a graphic around an alternate axis but I can only ever get it to rotate around the center point no matter what I do, putting in postTranlate. preTranslate, set Translate in any order doesnt work I have also tried the postRotate(45,0,0) but it always rotates around the center. Code below taken of internet what would I do to alter its rotation point, the code below uses the launcher icon which is square I am using a long thin graphic like an arrow. Thanks



// Rotate image to 45 degrees.

public void RotateImage(){
ImageView image;
Bitmap bMap;
Matrix matrix;

//Get ImageView from layout xml file
image = (ImageView) findViewById(R.id.imageView1);

//Decode Image using Bitmap factory.
bMap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);

//Create object of new Matrix.
matrix = new Matrix();

//set image rotation value to 45 degrees in matrix.
matrix.postRotate(45);

//Create bitmap with new values.
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0,
bMap.getWidth(), bMap.getHeight(), matrix, true);

//put rotated image in ImageView.
image.setImageBitmap(bMapRotate);
}


asked 28 secs ago







Rotate around alternate axis

Aucun commentaire:

Enregistrer un commentaire