android.graphics.Matrix#setConcat ( )源码实例Demo

下面列出了android.graphics.Matrix#setConcat ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Camera2   文件: CameraCoordinateTransformer.java
private Matrix cameraToPreviewTransform(boolean mirrorX, int displayOrientation,
                                        RectF previewRect)
{
    Matrix transform = new Matrix();

    // Need mirror for front camera.
    transform.setScale(mirrorX ? -1 : 1, 1);

    // Apply a rotate transform.
    // This is the value for android.hardware.Camera.setDisplayOrientation.
    transform.postRotate(displayOrientation);

    // Map camera driver coordinates to preview rect coordinates
    Matrix fill = new Matrix();
    fill.setRectToRect(CAMERA_DRIVER_RECT,
            previewRect,
            Matrix.ScaleToFit.FILL);

    // Concat the previous transform on top of the fill behavior.
    transform.setConcat(fill, transform);

    return transform;
}
 
源代码2 项目: CSipSimple   文件: MaxScaleImageView.java
private void updateScale() {
    Drawable d = getDrawable();
    if(d instanceof BitmapDrawable) {
        BitmapDrawable bd = (BitmapDrawable) d;

        // Don't upscale if more than 2x larger
        if (getWidth() > mMaxScale * bd.getIntrinsicWidth()
                && getHeight() > mMaxScale * bd.getIntrinsicHeight()) {
            setScaleType(ScaleType.MATRIX);
            Matrix trans = new Matrix();
            Matrix scale = new Matrix();
            trans.setTranslate((getWidth() - mMaxScale * bd.getIntrinsicWidth())/2, (getHeight() - mMaxScale * bd.getIntrinsicHeight())/2);
            scale.setScale(mMaxScale, mMaxScale);
            Matrix m = new Matrix();
            
            if(isInEditMode()) {
                // WTF? Edit mode consider inversed matrix??
                m.setConcat(scale, trans);
            }else {
                m.setConcat(trans, scale);
            }
            setImageMatrix(m);
        }else {
            setScaleType(ScaleType.CENTER_CROP);
        }
    }
}
 
源代码3 项目: CustomViewSets   文件: HorizontalCarouselLayout.java
protected boolean getChildStaticTransformation(View child, Transformation t) {
    Camera camera = new Camera();
    int leftCenterView = this.mWidthCenter - this.mChildrenWidthMiddle;
    float offset = (-child.getLeft() + leftCenterView) /
            this.mSpaceBetweenViews;
    if (offset != 0.0F) {
        float absOffset = Math.abs(offset);
        float scale = (float) Math.pow(0.8999999761581421D, absOffset);
        t.clear();
        t.setTransformationType(Transformation.TYPE_MATRIX);
        t.setAlpha(this.mSetInactiveViewTransparency);
        Matrix m = t.getMatrix();
        m.setScale(scale, scale);
        if (this.mTranslatateEnbabled) {
            m.setTranslate(0.0F, this.mTranslate * absOffset);
        }
        if (offset > 0.0F) {
            camera.save();
            camera.translate(0.0F, 0.0F, this.mViewZoomOutFactor * offset);
            camera.rotateY(this.mCoverflowRotation);
            camera.getMatrix(m);
            camera.restore();
            m.preTranslate(-this.mChildrenWidthMiddle, -this.mChildrenHeight);
            m.postTranslate(this.mChildrenWidthMiddle, this.mChildrenHeight);
        } else {
            camera.save();
            camera.translate(0.0F, 0.0F, -(this.mViewZoomOutFactor * offset));
            camera.rotateY(-this.mCoverflowRotation);
            camera.getMatrix(m);
            camera.restore();
            m.preTranslate(-this.mChildrenWidthMiddle, -this.mChildrenHeight);
            m.postTranslate(this.mChildrenWidthMiddle, this.mChildrenHeight);
        }
        this.mMatrix.reset();
        if (this.mRotationEnabled) {
            this.mMatrix.setRotate(this.mRotation * offset);
        }
        this.mMatrix.preTranslate(-this.mChildrenWidthMiddle, -this.mChildrenHeightMiddle);
        this.mMatrix.postTranslate(this.mChildrenWidthMiddle, this.mChildrenHeightMiddle);
        m.setConcat(m, this.mMatrix);
    }
    return true;
}