Matrix matrix = new Matrix(); if (rotation != 0f) {matrix.preRotate(rotationInDegrees);}
Matrix rotateRight = new Matrix(); rotateRight.preRotate(90); if(android.os.Build.VERSION.SDK_INT>13 && CameraActivity.frontCamera) { float[] mirrorY = { -1, 0, 0, 0, 1, 0, 0, 0, 1}; rotateRight = new Matrix(); Matrix matrixMirrorY = new Matrix(); matrixMirrorY.setValues(mirrorY); rotateRight.postConcat(matrixMirrorY); rotateRight.preRotate(270); } final Bitmap rImg= Bitmap.createBitmap(img, 0, 0, img.getWidth(), img.getHeight(), rotateRight, true);
Matrix matrix = new Matrix(); float rotation = PhotoTaker.rotationForImage(context, uri); if (rotation != 0f) { matrix.preRotate(rotation); } Bitmap resizedBitmap = Bitmap.createBitmap( sourceBitmap, 0, 0, width, height, matrix, true);
mtx.preRotate(rotate);
Matrix matrix = new Matrix(); // rotate the Bitmap (there a problem with exif so we'll query the mediaStore for orientation Cursor cursor = getApplicationContext().getContentResolver().query(selectedImage, new String[] { MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null); if (cursor.getCount() == 1) { cursor.moveToFirst(); int orientation = cursor.getInt(0); matrix.preRotate(orientation); }
final int[] colors = {circle_start_color, circle_end_color}; final float[] positions = {0f, 1f}; Gradient gradient = new SweepGradient(circle_bounds.centerX(), circle_bounds.centerY(), colors, positions); float rotate = 270f; Matrix gradientMatrix = new Matrix(); gradientMatrix.preRotate(rotate, circle_bounds.centerX(), circle_bounds.centerY()); gradient.setLocalMatrix(gradientMatrix); mPaint.setShader(gradient);
@Override protected void drawCompass(Canvas canvas, float bearing) { Resources res = _context.getResources(); Bitmap myCompassPointer = BitmapFactory.decodeResource(res, R.drawable.compass_pointer); float rotationAngle = -bearing + 360f; Matrix rotation = new Matrix(); rotation.preRotate(rotationAngle, myCompassPointer.getWidth()/2.0f, myCompassPointer.getHeight()/2.0f); canvas.drawBitmap(myCompassPointer, rotation, null); // don't call super if you don't want the default compass image: //super.drawCompass(canvas, bearing); }
if (this.getResources().getConfiguration().orientation != Configuration.UI_MODE_TYPE_CAR) { Matrix mat = new Matrix(); mat.preRotate(90); Bitmap rotated = Bitmap.createBitmap(bmpResult, 0, 0, myImage.getWidth(), myImage.getHeight(), mat, true); }
Matrix mat = new Matrix(); mat.preRotate(angle);///in degree Bitmap mBitmap = Bitmap.createBitmap(originalBmp, 0, 0, modWidth, modHeight, mat, true); //originalBmp -> original img as bitmap //modHeight -> new height //modWidth -> new width
// Load a bitmap from a drawable, make sure this drawable exists in your project Bitmap sprite = BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_launcher); // Create two matrices that will be used to rotate the bitmap Matrix rotateRight = new Matrix(); Matrix rotateLeft = new Matrix(); // Set the matrices with the desired rotation 90 or -90 degrees rotateRight.preRotate(90); rotateLeft.preRotate(-90); // Create bitmaps based on the loaded bitmap 'sprite' and apply one of // the rotation matrices Bitmap rSprite = Bitmap.createBitmap(sprite, 0, 0, sprite.getWidth(), sprite.getHeight(), rotateRight, true); Bitmap lSprite = Bitmap.createBitmap(sprite, 0, 0, sprite.getWidth(), sprite.getHeight(), rotateLeft, true);
private void ImageOrientation(File file,int rotate){ try { FileInputStream fis = new FileInputStream(file); filePath = file.getAbsolutePath(); Bitmap photo = BitmapFactory.decodeStream(fis); Matrix matrix = new Matrix(); matrix.preRotate(rotate); // clockwise by 90 degrees photo = Bitmap.createBitmap(photo , 0, 0, photo.getWidth(), photo.getHeight(), matrix, true); customerImageView.setImageBitmap(photo); imageBitmap = photo; } catch (FileNotFoundException e) { e.printStackTrace(); } }
myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath(),optionss); ExifInterface exif = new ExifInterface(selectedImagePath); int rotation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); int rotationInDegrees = exifToDegrees(rotation); deg = rotationInDegrees; Matrix matrix = new Matrix(); if (rotation != 0f) { matrix.preRotate(rotationInDegrees); myBitmap = Bitmap.createBitmap(myBitmap, 0, 0, myBitmap.getWidth(), myBitmap.getHeight(), matrix, true); }
float[] ptArr = new float[] { 20, 30, 60, 30, 60, 45, 20, 45}; Matrix m = new Matrix(); m.preRotate(angle, px, py); // where px and py is pivot point. m.mapPoints(ptArr); //at this point your array will be updated. canvas.drawPoints(ptArr, mPaint);
File curFile = new File("path-to-file"); // ... This is an image file from my device. Bitmap rotatedBitmap; try { ExifInterface exif = new ExifInterface(curFile.getPath()); int rotation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); int rotationInDegrees = exifToDegrees(rotation); Matrix matrix = new Matrix(); if (rotation != 0f) {matrix.preRotate(rotationInDegrees);} rotatedBitmap = Bitmap.createBitmap(bitmap,0,0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); }catch(IOException ex){ Log.e(TAG, "Failed to get Exif data", ex); }
Matrix transform = new Matrix(); transform.setTranslate(xOfCentre, yOfCentre); transform.preRotate(turnDegrees, width/2, height/2); canvas.drawBitmap(bitmap, transform, null);
float[] src = {x0,y0,x1,y1}; float[] dist = new float[4]; Matrix matrix = new Matrix(); matrix.preRotate(90.0f); matrix.mapPoints(dist,src);
.. final Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); matrix.preRotate(degrees); // recreate the new Bitmap final Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, x, y, width, height, matrix, true); ..
Matrix matrix = new Matrix(); matrix.preRotate(90); // or matrix.postRotate(90);
Matrix transform = new Matrix(); transform.setTranslate(dx, dy);// transform.preRotate(degree,PivotX ,PivotY); canvas.drawBitmap(bitmap, transform, null);
Matrix rotateRight = new Matrix(); rotateRight.preRotate(90); if(android.os.Build.VERSION.SDK_INT>13 && CameraActivity.frontCamera) { float[] mirrorY = { -1, 0, 0, 0, 1, 0, 0, 0, 1}; rotateRight = new Matrix(); Matrix matrixMirrorY = new Matrix(); matrixMirrorY.setValues(mirrorY); rotateRight.postConcat(matrixMirrorY); rotateRight.preRotate(270); } final Bitmap rImg= Bitmap.createBitmap(img, 0, 0, img.getWidth(), img.getHeight(), rotateRight, true);