use of android.graphics.Matrix in project picasso by square.
the class BitmapHunterTest method exifRotationWithManualRotation.
@Test
public void exifRotationWithManualRotation() {
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Request data = new Request.Builder(URI_1).rotate(-45).build();
Bitmap result = transformResult(data, source, ORIENTATION_ROTATE_90);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPreOperations()).containsOnly("rotate 90.0");
assertThat(shadowMatrix.getSetOperations()).contains(entry("rotate", "-45.0"));
}
use of android.graphics.Matrix in project picasso by square.
the class BitmapHunterTest method centerCropResultMatchesTargetSizeWhileDesiredWidthIs0.
@Test
public void centerCropResultMatchesTargetSizeWhileDesiredWidthIs0() {
Request request = new Request.Builder(URI_1).resize(0, 642).centerCrop().build();
Bitmap source = Bitmap.createBitmap(640, 640, ARGB_8888);
Bitmap result = transformResult(request, source, 0);
ShadowBitmap shadowBitmap = shadowOf(result);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
String scalePreOperation = shadowMatrix.getPreOperations().get(0);
assertThat(scalePreOperation).startsWith("scale ");
float scaleX = Float.valueOf(scalePreOperation.split(" ")[1]);
float scaleY = Float.valueOf(scalePreOperation.split(" ")[2]);
int transformedWidth = Math.round(result.getWidth() * scaleX);
int transformedHeight = Math.round(result.getHeight() * scaleY);
assertThat(transformedWidth).isEqualTo(642);
assertThat(transformedHeight).isEqualTo(642);
}
use of android.graphics.Matrix in project picasso by square.
the class BitmapHunterTest method exifTranspose.
@Test
public void exifTranspose() {
Request data = new Request.Builder(URI_1).rotate(-45).build();
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Bitmap result = transformResult(data, source, ORIENTATION_TRANSPOSE);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPostOperations()).containsOnly("scale -1.0 1.0");
assertThat(shadowMatrix.getPreOperations()).containsOnly("rotate 90.0");
}
use of android.graphics.Matrix in project ZoomableImageView by laurencedawson.
the class ZoomableImageView method zoomOut.
// Unchanged from ImageViewTouchBase
protected void zoomOut(float rate) {
if (mBitmap == null) {
return;
}
float width = getWidth();
float height = getHeight();
Matrix tmp = new Matrix(mSuppMatrix);
tmp.postScale(1F / sScaleRate, 1F / sScaleRate, width / 2F, height / 2F);
if (getScale(tmp) < 1F) {
mSuppMatrix.setScale(1F, 1F, width / 2F, height / 2F);
} else {
mSuppMatrix.postScale(1F / rate, 1F / rate, width / 2F, height / 2F);
}
setImageMatrix(getImageViewMatrix());
center(true, true, false);
}
use of android.graphics.Matrix in project react-native-camera by lwansbrough.
the class RCTCameraModule method mirrorImage.
private byte[] mirrorImage(byte[] data) {
ByteArrayInputStream inputStream = new ByteArrayInputStream(data);
Bitmap photo = BitmapFactory.decodeStream(inputStream);
Matrix m = new Matrix();
m.preScale(-1, 1);
Bitmap mirroredImage = Bitmap.createBitmap(photo, 0, 0, photo.getWidth(), photo.getHeight(), m, false);
return saveImage(inputStream, mirroredImage);
}
Aggregations