Search in sources :

Example 86 with Matrix

use of android.graphics.Matrix in project fresco by facebook.

the class ScaleTypeDrawableTest method testConfigureBounds_FOCUS_CROP_VC.

/**
   * Underlying drawable's aspect ratio is smaller than view's, so it has to be slided vertically
   * after scaling. Focus point is at 40% and it can be completely centered.
   */
@Test
public void testConfigureBounds_FOCUS_CROP_VC() {
    Rect bounds = new Rect(10, 10, 410, 310);
    int width = 200;
    int height = 300;
    PointF focusPoint = new PointF(0.5f, 0.4f);
    Matrix expectedMatrix = new Matrix();
    expectedMatrix.setScale(2.0f, 2.0f);
    expectedMatrix.postTranslate(10, -79);
    testConfigureBounds(bounds, width, height, ScaleType.FOCUS_CROP, focusPoint, expectedMatrix);
    // expected bounds of the actual image after the scaling has been performed (without cropping)
    testActualImageBounds(new RectF(10f, -79f, 410f, 521f));
}
Also used : RectF(android.graphics.RectF) Rect(android.graphics.Rect) Matrix(android.graphics.Matrix) PointF(android.graphics.PointF) Test(org.junit.Test)

Example 87 with Matrix

use of android.graphics.Matrix in project fresco by facebook.

the class OrientedDrawableTest method testCreation_hundredAndEightyDegrees.

@Test
public void testCreation_hundredAndEightyDegrees() {
    OrientedDrawable drawable = new OrientedDrawable(mDrawable, 180);
    drawable.setBounds(mBounds);
    drawable.draw(mCanvas);
    Matrix expectedMatrix = new Matrix();
    expectedMatrix.setRotate(180, drawable.getBounds().centerX(), drawable.getBounds().centerY());
    assertFalse(drawable.mRotationMatrix.isIdentity());
    AndroidGraphicsTestUtils.assertEquals(expectedMatrix, drawable.mRotationMatrix);
    verifySetBounds(expectedMatrix);
}
Also used : Matrix(android.graphics.Matrix) Test(org.junit.Test)

Example 88 with Matrix

use of android.graphics.Matrix in project fresco by facebook.

the class ScaleTypeDrawableTest method testConfigureBounds_FOCUS_CROP_HC.

/**
   * Underlying drawable's aspect ratio is bigger than view's, so it has to be slided horizontally
   * after scaling. Focus point is at 40% and it can be completely centered.
   */
@Test
public void testConfigureBounds_FOCUS_CROP_HC() {
    Rect bounds = new Rect(10, 10, 410, 310);
    int width = 400;
    int height = 200;
    PointF focusPoint = new PointF(0.40f, 0.5f);
    Matrix expectedMatrix = new Matrix();
    expectedMatrix.setScale(1.5f, 1.5f);
    expectedMatrix.postTranslate(-29, 10);
    testConfigureBounds(bounds, width, height, ScaleType.FOCUS_CROP, focusPoint, expectedMatrix);
}
Also used : Rect(android.graphics.Rect) Matrix(android.graphics.Matrix) PointF(android.graphics.PointF) Test(org.junit.Test)

Example 89 with Matrix

use of android.graphics.Matrix in project fresco by facebook.

the class ScaleTypeDrawableTest method testConfigureBounds_FOCUS_CROP_VB.

/**
   * Underlying drawable's aspect ratio is smaller than view's, so it has to be slided vertically
   * after scaling. Focus point is too much bottom, so it cannot be completely centered. Bottom-most
   * part of the image is displayed.
   */
@Test
public void testConfigureBounds_FOCUS_CROP_VB() {
    Rect bounds = new Rect(10, 10, 410, 310);
    int width = 200;
    int height = 300;
    PointF focusPoint = new PointF(0.5f, 0.9f);
    Matrix expectedMatrix = new Matrix();
    expectedMatrix.setScale(2.0f, 2.0f);
    expectedMatrix.postTranslate(10, -289);
    testConfigureBounds(bounds, width, height, ScaleType.FOCUS_CROP, focusPoint, expectedMatrix);
}
Also used : Rect(android.graphics.Rect) Matrix(android.graphics.Matrix) PointF(android.graphics.PointF) Test(org.junit.Test)

Example 90 with Matrix

use of android.graphics.Matrix in project Keyframes by facebookincubator.

the class KFPathTest method testSimpleCommands.

@Test
public void testSimpleCommands() {
    KFPathTestObject kfPathWrapper = new KFPathTestObject();
    InOrder orderedMock = Mockito.inOrder(kfPathWrapper.mockPath);
    kfPathWrapper.kfPath.isEmpty();
    orderedMock.verify(kfPathWrapper.mockPath).isEmpty();
    Matrix matrix = new Matrix();
    kfPathWrapper.kfPath.transform(matrix);
    orderedMock.verify(kfPathWrapper.mockPath).transform(matrix);
}
Also used : InOrder(org.mockito.InOrder) Matrix(android.graphics.Matrix) Test(org.junit.Test)

Aggregations

Matrix (android.graphics.Matrix)970 Bitmap (android.graphics.Bitmap)254 Paint (android.graphics.Paint)201 RectF (android.graphics.RectF)155 Rect (android.graphics.Rect)99 Test (org.junit.Test)93 Canvas (android.graphics.Canvas)80 ImageView (android.widget.ImageView)67 View (android.view.View)65 Point (android.graphics.Point)52 Bundle (android.os.Bundle)45 GhostView (android.view.GhostView)40 ViewGroup (android.view.ViewGroup)39 ColorMatrix (android.graphics.ColorMatrix)38 Drawable (android.graphics.drawable.Drawable)38 IOException (java.io.IOException)38 BitmapHunter.forRequest (com.squareup.picasso.BitmapHunter.forRequest)36 TestUtils.makeBitmap (com.squareup.picasso.TestUtils.makeBitmap)36 ShadowBitmap (org.robolectric.shadows.ShadowBitmap)36 ShadowMatrix (org.robolectric.shadows.ShadowMatrix)36