Java Code Examples for android.graphics.Camera#setLocation()

The following examples show how to use android.graphics.Camera#setLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RotateView.java    From WanAndroid with Apache License 2.0 6 votes vote down vote up
public RotateView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.RotateView);
    BitmapDrawable bitmapDrawable = (BitmapDrawable) array.getDrawable(R.styleable.RotateView_viewBackgound2);
    array.recycle();

    if (bitmapDrawable != null) {

        bitmap = bitmapDrawable.getBitmap();
        byte[] bytes = BitmapUtil.bitmap2Bytes(bitmap);
        bitmap = BitmapUtil.resizeBitmapBytes(bytes);
    }else {
        bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
    }

    camera = new Camera();
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    float newZ = -metrics.density * 6;
    camera.setLocation(0, 0, newZ);
}
 
Example 2
Source File: ShuttersConsumer.java    From SmartSwipe with Apache License 2.0 4 votes vote down vote up
public ShuttersConsumer() {
    setReleaseMode(RELEASE_MODE_AUTO_OPEN_CLOSE);
    mCamera = new Camera();
    mCamera.setLocation(0,0, -20);
    mPaint = new Paint();
}
 
Example 3
Source File: ViewPropertyAnimation.java    From FragmentAnimations with Apache License 2.0 4 votes vote down vote up
protected void applyTransformation(Transformation t) {
    final Matrix m = t.getMatrix();
    final float w = mWidth;
    final float h = mHeight;
    final float pX = mPivotX;
    final float pY = mPivotY;

    final float rX = mRotationX;
    final float rY = mRotationY;
    final float rZ = mRotationZ;
    if ((rX != 0) || (rY != 0) || (rZ != 0)) {
        final Camera camera = mCamera;
        camera.save();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
            camera.setLocation(mCameraX, mCameraY, mCameraZ);
        }
        if (mTranslationZ != 0) {
            camera.translate(0, 0, mTranslationZ);
        }
        camera.rotateX(rX);
        camera.rotateY(rY);
        camera.rotateZ(-rZ);
        camera.getMatrix(m);
        camera.restore();
        m.preTranslate(-pX, -pY);
        m.postTranslate(pX, pY);
    }

    final float sX = mScaleX;
    final float sY = mScaleY;
    if ((sX != 1.0f) || (sY != 1.0f)) {
        m.postScale(sX, sY);
        final float sPX = -(pX / w) * ((sX * w) - w);
        final float sPY = -(pY / h) * ((sY * h) - h);
        m.postTranslate(sPX, sPY);
    }

    m.postTranslate(mTranslationX, mTranslationY);

    t.setAlpha(mAlpha);
}