本文整理匯總了Java中android.graphics.Camera類的典型用法代碼示例。如果您正苦於以下問題:Java Camera類的具體用法?Java Camera怎麽用?Java Camera使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Camera類屬於android.graphics包,在下文中一共展示了Camera類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: applyTransformation
import android.graphics.Camera; //導入依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
final float centerX = mCenterX;
final float centerY = mCenterY;
final Camera camera = mCamera;
final Matrix matrix = t.getMatrix();
camera.save();
if (mReverse) {
camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
} else {
camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
}
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
示例2: applyTransformation
import android.graphics.Camera; //導入依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float degrees = fromDegrees + ((toDegrees - fromDegrees) * interpolatedTime);
final Matrix matrix = t.getMatrix();
final Camera camera = mCamera;
camera.save();
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
示例3: SphereLayout
import android.graphics.Camera; //導入依賴的package包/類
public SphereLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SphereLayout);
mRadius = a.getDimensionPixelSize(R.styleable.SphereLayout_radius, 0);//球體半徑
mOrientation = a.getInt(R.styleable.SphereLayout_snapOrientation, HORIZONTAL);//標記位於背麵的視圖是以Y軸水平翻轉到達正麵 或是以X軸豎直翻轉可到達正麵
mHideBack = a.getBoolean(R.styleable.SphereLayout_hideBack, false);//是否隱藏處在背麵的布局
a.recycle();
mCenter = new Point();
mCamera = new Camera();
mDependencyOffset = new int[2];
//mCamera.setLocation(0, 0, -20);
mMatrix = new Matrix();
mPositiveChildren = new ArrayList<>();//depth為正的childview集合
mNegativeChildren = new ArrayList<>();//depth為負的childview集合
mDensity = getResources().getDisplayMetrics().density;
}
示例4: applyTransformation
import android.graphics.Camera; //導入依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
final float centerX = mCenterX;
final float centerY = mCenterY;
final Camera camera = mCamera;
final Matrix matrix = t.getMatrix();
camera.save();
if (mReverse) {
camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
} else {
camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
}
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
示例5: applyTransformation
import android.graphics.Camera; //導入依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
Camera camera = new Camera();
camera.save();
// 設置camera動作為繞Y軸旋轉
// 總共旋轉180度,因此計算在每個補間時間點interpolatedTime的角度即為兩著相乘
// camera.rotateX(deg * interpolatedTime);
camera.rotateY(180 * interpolatedTime);
// camera.rotateZ(180 * interpolatedTime);
//
// 根據camera動作產生一個matrix,賦給Transformation的matrix,以用來設置動畫效果
Matrix matrix = t.getMatrix();
camera.getMatrix(matrix);
camera.restore();
//經過以下平移,才能以view的中心點進行翻轉
matrix.preTranslate(-view.getWidth() / 2, -view.getHeight() / 2);
matrix.postTranslate(view.getWidth() / 2, view.getHeight() / 2);
}
示例6: applyTransformation
import android.graphics.Camera; //導入依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
final float centerX = mCenterX;
final float centerY = mCenterY;
final Camera camera = mCamera;
final Matrix matrix = t.getMatrix();
camera.save();
if (mReverse) {
camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
} else {
camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
}
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
示例7: drawIconOne
import android.graphics.Camera; //導入依賴的package包/類
/**
* 根據角度繪製圖標的類
* @param canvas 畫布
* @param fraction 完成時間百分比
* @param icon 圖標
* @param width view寬度
* @param height view高度
*/
private void drawIconOne(Canvas canvas, float fraction, Bitmap icon, int width, int height) {
Camera camera = new Camera();
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
canvas.save();
int centerX = width / 2;
int centerY = height / 2 - 200;
int x = centerX - icon.getWidth()/2;
int y = centerY - icon.getHeight()/2;
Matrix matrix = new Matrix();
matrix.postScale(1.7f, 1.7f, centerX, centerY);
canvas.concat(matrix);
canvas.clipRect(x, y, x + icon.getWidth() * fraction * 0.5f, y + icon.getHeight() * fraction * 0.5f);
canvas.translate(centerX, centerY);
camera.save();
camera.rotateX(180);
camera.rotateY(-180);
camera.applyToCanvas(canvas);
camera.restore();
canvas.translate(-centerX, -centerY);
canvas.drawBitmap(icon, x, y, paint);
canvas.restore();
}
示例8: RotateIndicatorView
import android.graphics.Camera; //導入依賴的package包/類
public RotateIndicatorView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.RotateIndicatorView, defStyleAttr, 0);
diameter = array.getDimensionPixelSize(R.styleable.RotateIndicatorView_diameter, 50);
textColor = array.getColor(R.styleable.RotateIndicatorView_textColor, Color.RED);
textBackgroundColor = array.getColor(R.styleable.RotateIndicatorView_textBackgroundColor, Color.WHITE);
maxPage = array.getInt(R.styleable.RotateIndicatorView_maxPage, 1);
rightBitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.indicator2);
Matrix matrix = new Matrix();
float scale = 1.0f * diameter / rightBitmap.getHeight();
matrix.postScale(scale, scale);
rightBitmap = Bitmap.createBitmap(rightBitmap, 0, 0, rightBitmap.getWidth(), rightBitmap.getHeight(), matrix, true);
mPaint = new Paint();
camera = new Camera();
}
示例9: skewImage
import android.graphics.Camera; //導入依賴的package包/類
/**
* 3D效果
*
* @param srcBitmap
* @return
*/
public static Bitmap skewImage(Bitmap srcBitmap, int picWidth, int picHeight, int height) {
srcBitmap = Bitmap.createScaledBitmap(srcBitmap, picWidth, picHeight, true);
Bitmap bitmap = createReflectedImage(srcBitmap, height);
Camera camera = new Camera();
camera.save();
Matrix matrix = new Matrix();
camera.rotateY(15);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-bitmap.getWidth() >> 1, -bitmap.getHeight() >> 1);
Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
Bitmap canvasBitmap = Bitmap.createBitmap(newBitmap.getWidth(), newBitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(canvasBitmap);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
// paint.setStyle(Style.FILL);
canvas.drawBitmap(newBitmap, 0, 0, paint);
newBitmap.recycle();
// bitmap.recycle();
return canvasBitmap;
}
示例10: applyTransformation
import android.graphics.Camera; //導入依賴的package包/類
/**
* 執行順序 matrix.preTranslate() --> camera.rotateY(degrees) --> matrix.postTranslate() --> matrix.postScale()
* @param interpolatedTime
* @param t
*/
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float degrees = mReverse ? mToDegrees + (mFromDegrees - mToDegrees) * interpolatedTime : mFromDegrees + (mToDegrees - mFromDegrees) * interpolatedTime;
final Matrix matrix = t.getMatrix();
final Camera camera = mCamera;
camera.save();
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
// matrix.preTranslate(-mPivotXValue, 0); //在進行rotateY之前需要移動物體,讓物體左邊與Y軸對齊
// matrix.postTranslate(mPivotXValue, 0); //還原物體位置
if (mReverse) {
matrix.postScale(1 + (scaleTimes - 1) * (1.0f - interpolatedTime), 1 + (scaleTimes - 1) * (1.0f - interpolatedTime), mPivotX - mPivotXValue , mPivotY - mPivotYValue);
} else {
// matrix.postScale(1 + (scaleTimes - 1) * interpolatedTime, 1 + (scaleTimes - 1) * interpolatedTime, mPivotX, mPivotY);
matrix.postScale(1 + (scaleTimes - 1) * interpolatedTime, 1 + (scaleTimes - 1) * interpolatedTime, mPivotX - mPivotXValue , mPivotY - mPivotYValue );
}
}
示例11: applyTransformation
import android.graphics.Camera; //導入依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
final float centerX = mCenterX;
final float centerY = mCenterY;
final Camera camera = mCamera;
final int derection = mTurnUp ? 1 : -1;
final Matrix matrix = t.getMatrix();
camera.save();
if (mTurnIn) {
camera.translate(0.0f, derection * mCenterY * (interpolatedTime - 1.0f), 0.0f);
} else {
camera.translate(0.0f, derection * mCenterY * (interpolatedTime), 0.0f);
}
camera.rotateX(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
示例12: applyTransformation
import android.graphics.Camera; //導入依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float tmpFromDegrees = fromDegrees;
float degrees = tmpFromDegrees + ((toDegrees - tmpFromDegrees) * interpolatedTime);
float tmpCenterX = centerX;
float tmpCenterY = centerY;
Camera tmpCamera = camera;
Matrix matrix = t.getMatrix();
LogUtils.d("interpolatedTime: " + interpolatedTime);
tmpCamera.save();
if (reverse) {
tmpCamera.translate(0f, 0f, depthZ * interpolatedTime);
} else {
tmpCamera.translate(0f, 0f, depthZ * (1.0f - interpolatedTime));
}
tmpCamera.rotateY(degrees);
tmpCamera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-tmpCenterX, -tmpCenterY);
matrix.postTranslate(tmpCenterX, tmpCenterY);
super.applyTransformation(interpolatedTime, t);
}
示例13: applyTransformation
import android.graphics.Camera; //導入依賴的package包/類
@Override protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
final float centerX = mCenterX;
final float centerY = mCenterY;
final Camera camera = mCamera;
final Matrix matrix = t.getMatrix();
camera.save();
if (mReverse) {
camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
} else {
camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
}
camera.setLocation(0, 0, 60);
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
示例14: applyTransformation
import android.graphics.Camera; //導入依賴的package包/類
/**
* 執行順序 matrix.preTranslate() --> camera.rotateY(degrees) --> matrix.postTranslate() --> matrix.postScale()
* @param interpolatedTime
* @param t
*/
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float degrees = mReverse ? mToDegrees + (mFromDegrees - mToDegrees) * interpolatedTime : mFromDegrees + (mToDegrees - mFromDegrees) * interpolatedTime;
final Matrix matrix = t.getMatrix();
final Camera camera = mCamera;
camera.save();
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-mPivotXValue, 0); //在進行rotateY之前需要移動物體,讓物體左邊與Y軸對齊
matrix.postTranslate(mPivotXValue, 0); //還原物體位置
if (mReverse) {
matrix.postScale(1 + (scaleTimes - 1) * (1.0f - interpolatedTime), 1 + (scaleTimes - 1) * (1.0f - interpolatedTime), mPivotX, mPivotY);
} else {
matrix.postScale(1 + (scaleTimes - 1) * interpolatedTime, 1 + (scaleTimes - 1) * interpolatedTime, mPivotX, mPivotY);
}
}
示例15: applyTransformation
import android.graphics.Camera; //導入依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
final Camera camera = mCamera;
final Matrix matrix = t.getMatrix();
camera.save();
if (mReverse) {
camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
} else {
camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
}
camera.rotateX(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-mCenterX * mWidth, -mCenterY * mHeight);
matrix.postTranslate(mCenterX * mWidth, mCenterY * mHeight);
}