當前位置:首頁 » 安卓系統 » android讓圖片旋轉

android讓圖片旋轉

發布時間: 2022-06-23 08:04:51

① Android中怎麼使一張圖片繞Y軸自動旋轉

動畫animation能實現圍繞自身某個點旋轉和圍繞外部屏幕上某個點旋轉.

② android 中用畫布旋轉圖片的時候怎麼讓讓他 圍著一個坐標旋轉

方法只有一種。

步驟:

1、畫布平移坐標原點

2、旋轉畫布

示例代碼

java">canvas.save();//保存當前畫布狀態
canvas.translate(x,y);//將坐標中心平移到要圍繞的坐標點x,y
canvas.rotate(90);//旋轉角度,這里比如90度
canvas.restore();//恢復畫圖狀態到保存前

③ android 怎麼讓圖片實現朝Z軸的方向旋轉RotateAnimation是x y方向的,我想要包含z方向的

RotateAnimation是不可以繞Z軸旋轉的,如果LZ想要實現Z軸旋轉效果,可以看下matrix這個類(實際還是opengl),可以給LZ例舉下:
rotateX(float degree) 繞著x軸旋轉degree個度數
rotateY(float degree) 繞著y軸旋轉degree個度數
rotateZ(float degree) 繞著z軸旋轉degree個度數

④ android開發中讓圖片旋轉發生outofmemory錯誤要怎麼解決

沒什麼好辦法,載入Bitmap的時候已經佔用內存了,你一讓它旋轉,它會重新調用OnDraw方法,將界面重新繪制一下,又佔用了一塊內存,沒有思路。要不你試試將圖片縮小一下再試試。

⑤ android 怎麼得到手機拍照照片的旋轉角度

具體思路:
1、首先在調用拍照方法時,保存拍照後的相片原圖,得到原圖路徑,(PhotoBitmapUtils是我自己寫的一個工具類)

String fileName = "";
/**
* 啟動相機拍照
*/
private void addBitmapShoots() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// 設置圖片要保存的 根路徑+文件名
fileName = PhotoBitmapUtils.getPhotoFileName(getContext());
File file = new File(fileName);
if (!file.exists()) {
try {
file.createNewFile();

⑥ android怎麼實現圖片旋轉

可以使用RotateAnimation動畫實現,設定無限循環即可

代碼如下

{

ImageViewiv;
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_two);
iv=(ImageView)findViewById(R.id.image);
RotateAnimationanimation=newRotateAnimation(0,360);
animation.setDuration(100000);//設定轉一圈的時間
animation.setRepeatCount(Animation.INFINITE);//設定無限循環
animation.setRepeatMode(Animation.RESTART);
iv.startAnimation(animation);
}
}


也可以自定義view繼承於imageview,啟動一個線程,在while循環里設置view的旋轉角度


{

privatefloatmCurDegree=0;//當前旋轉角度
publicRotateView(Contextcontext,AttributeSetattrs){
super(context,attrs);
newThread(this).start();
}

@Override
protectedvoidonLayout(booleanchanged,intleft,inttop,intright,
intbottom){
super.onLayout(changed,left,top,right,bottom);
//設定旋轉中心
setPivotX(getMeasuredWidth()/2);
setPivotY(getMeasuredHeight()/2);
}

@Override
publicvoidrun(){
while(true){
setRotation(mCurDegree);
mCurDegree+=5;
postInvalidate();
SystemClock.sleep(16);
}
}
}

在布局文件里使用RotateView代替imageview即可

⑦ Android 如何通過帽子右下角的按鈕來控制圖片的縮放和旋轉

Android中對圖片處理應用比較常見,所以整理了一些對圖片的基本操作處理功能方法:
/**
* 圖片反轉
* @param img
* @return
*/
public Bitmap toturn(Bitmap img){
Matrix matrix = new Matrix();
matrix.postRotate(90); /*翻轉90度*/
int width = bitmap.getWidth();
int height =bitmap.getHeight();
img = Bitmap.createBitmap(img, 0, 0, width, height, matrix, true);
return img;
}
/**
* 圖片縮放
* @param bigimage
* @param newWidth
* @param newHeight
* @return
*/
public Bitmap tochange(Bitmap bigimage,int newWidth,int newHeight){
// 獲取這個圖片的寬和高
int width = bigimage.getWidth();
int height = bigimage.getHeight();
// 創建操作圖片用的matrix對象
Matrix matrix = new Matrix();
// 計算縮放率,新尺寸除原始尺寸
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
// 縮放圖片動作
matrix.postScale(scaleWidth, scaleHeight);
Bitmap bitmap = Bitmap.createBitmap(bigimage, 0, 0, width, height,matrix, true);
return bitmap;
}

/**
* 程序切割圖片
* @param bitmap
* @param x
* @param y
* @param w
* @param h
* @return
*/
public Bitmap BitmapClipBitmap(Bitmap bitmap,int x, int y, int w, int h) {
return Bitmap.createBitmap(bitmap, x, y, w, h);
}
/**
* 圖片疊加
* @param b
* @return
*/
public Bitmap diejia(Bitmap b){

if(!b.isMutable()){

熱點內容
二級程序編譯答案 發布:2024-05-03 18:41:35 瀏覽:652
領動自動精英版是哪個配置 發布:2024-05-03 18:37:30 瀏覽:149
java編譯器中cd什麼意思 發布:2024-05-03 18:36:00 瀏覽:388
傳奇伺服器如何刷錢 發布:2024-05-03 18:36:00 瀏覽:976
安卓版twitter怎麼注冊 發布:2024-05-03 18:28:05 瀏覽:893
Python邏輯優先順序 發布:2024-05-03 18:26:14 瀏覽:266
linux查看svn密碼 發布:2024-05-03 18:12:47 瀏覽:803
地鐵逃生怎麼進入游戲安卓 發布:2024-05-03 17:49:35 瀏覽:992
aws雲存儲 發布:2024-05-03 17:48:50 瀏覽:954
安卓微信王者號怎麼轉成蘋果 發布:2024-05-03 17:44:38 瀏覽:745