Friday, September 9, 2016
Monday, February 15, 2016
Android Image Rotation
Note: Don't forget to create ImageView in your layout xml file with android:id="@+id/imageView1 /*** 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); }
Subscribe to:
Posts (Atom)