當前位置:首頁 » 安卓系統 » android拍照旋轉

android拍照旋轉

發布時間: 2022-04-30 02:34:41

❶ 現在 做了個 android 視頻錄制的程序 ,後置攝像頭總是旋轉90度,如何用代碼實現正常。

MediaRecorder 中一個方法setCamera();所以可以先設置好攝像頭的參數,然後再設置到MediaRecorder 中(但是錄制前需要解鎖)。
部分關鍵的代碼如果下:
//初始化相機信息
Camera mCamera = Camera.open();
Camera.Parameters params = mCamera.getParameters();
mCamera.setDisplayOrientation(90);//旋轉了90度,最好先判斷下JDK的版本號,再決定旋轉不
mCamera.setParameters(params);
mCamera.stopPreview();
mCamera.unlock();//解鎖
videoMediaRecorder.setCamera(mCamera);

❷ android 用 SurfaceView 預覽 拍照,豎屏時,顯示的圖像旋轉了90度,怎麼處理

設置activity不讓它重力感應

❸ android怎麼實現圖片旋轉

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

代碼如下

java">{

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的圖片旋轉後會被重繪嗎

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker :YES];
NSString* mediaType=[info objectForKey:];
if([mediaType isEqualToString:(NSString*)kUTTypeImage])//@"public.image"
{
UIImage* image=[info objectForKey:];
UIImageOrientation imageOrientation=image.imageOrientation;
if(imageOrientation!=UIImageOrientationUp)
{
// 原始圖片可以根據照相時的角度來顯示,但UIImage無法判定,於是出現獲取的圖片會向左轉90度的現象。
// 以下為調整圖片角度的部分
UIGraphicsBeginImageContext(image.size);
[image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
iPortraitImageView.image = ();
UIGraphicsEndImageContext();
// 調整圖片角度完畢
}
}
}

❺ 為很么在Android程序中調用前置攝像頭獲得的預覽圖像旋轉了一百八十度註:在系統相機中是正常的

你把這個軟體放在其他手機上照相試下,如果還是那樣,那就是你下載的軟體有問題。

❻ android怎麼實現一張圖片旋轉幾秒後後自動換到另一張圖片

圖片旋轉使用動畫,設置動畫時間,旋轉完成後,設置另一張圖片

RotateAnimation 動畫,
RotateAnimation (float fromDegrees, float toDegrees, int
pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
參數說明:

float fromDegrees:旋轉的開始角度。
float toDegrees:旋轉的結束角度。
int
pivotXType:X軸的伸縮模式,可以取值為ABSOLUTE、RELATIVE_TO_SELF、RELATIVE_TO_PARENT。
float
pivotXValue:X坐標的伸縮值。
int
pivotYType:Y軸的伸縮模式,可以取值為ABSOLUTE、RELATIVE_TO_SELF、RELATIVE_TO_PARENT。
float
pivotYValue:Y坐標的伸縮值。

❼ 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如何判斷手機攝像頭是否倒置或旋轉角度

攝像頭沒有裝倒這一說,說明你們開發的程序還是有瑕疵的,都是程序設定的,就好比你拿著手機拍照,不管你怎麼旋轉手機,圖像始終是朝下的,給你個提示:重力感應。

❾ 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();

熱點內容
密碼鎖aid代表什麼 發布:2025-05-11 18:00:01 瀏覽:755
編程的組成 發布:2025-05-11 17:58:34 瀏覽:806
火山易語言apk反編譯 發布:2025-05-11 17:52:01 瀏覽:813
鋼琴密碼鎖本的密碼該在哪裡看 發布:2025-05-11 17:49:44 瀏覽:468
in運演算法則 發布:2025-05-11 17:41:32 瀏覽:406
微信怎麼分身兩個賬號安卓 發布:2025-05-11 17:32:14 瀏覽:915
新人采訪問題 發布:2025-05-11 17:14:29 瀏覽:899
雲伺服器有私服嗎 發布:2025-05-11 17:13:33 瀏覽:30
安卓手機怎麼轉移ipad 發布:2025-05-11 17:01:35 瀏覽:735
電腦怎麼進華為雲伺服器 發布:2025-05-11 16:53:53 瀏覽:868