1.首先需要新增許可權:
2.增加activity
這裡的
android:screenorientation控制了掃瞄橫屏還是豎屏 橫屏landscape
3.修改decodehandler
增加乙個方法
public byte rotatedata(byte data,int width,int height)
return rotateddata;
}
對decode(byte data, int width, int height)方法進行修改
planaryuvluminancesource source = activity.getcameramanager().buildluminancesource(rotatedata(data, width, height), width, height);
4.修改cameraconfigurationmanager
因為這裡需要修改的地方比較多,我把整個**拿出來吧
修改initfromcameraparameters
void initfromcameraparameters(camera camera)
增加
private int previewformat;
private string previewformatstring;
private static final pattern comma_pattern = pattern.compile(",");
private static point getcameraresolution(camera.parameters parameters, point screenresolution)
point cameraresolution = null;
if (previewsizevaluestring != null)
if (cameraresolution == null)
return cameraresolution;
} private static point findbestpreviewsizevalue(charsequence previewsizevaluestring, point screenresolution)
int newx;
int newy;
try catch (numberformatexception nfe)
int newdiff = math.abs(newx - screenresolution.x) + math.abs(newy - screenresolution.y);
if (newdiff == 0) else if (newdiff < diff)
}if (bestx > 0 && besty > 0)
return null;
}
setdesiredcameraparameters方法裡增加camera.setdisplayorientation(90); //此句為轉為橫屏時增加的
cameramanager的修改這裡沒用到 ,還是記錄一下吧
getframingrectinpreview方法
//橫屏
rect.left = rect.left * cameraresolution.x / screenresolution.x;
rect.right = rect.right * cameraresolution.x / screenresolution.x;
rect.top = rect.top * cameraresolution.y / screenresolution.y;
rect.bottom = rect.bottom * cameraresolution.y / screenresolution.y;
//豎屏
// rect.left = rect.left * cameraresolution.y / screenresolution.x;
// rect.right = rect.right * cameraresolution.y / screenresolution.x;
// rect.top = rect.top * cameraresolution.x / screenresolution.y;
// rect.bottom = rect.bottom * cameraresolution.x / screenresolution.y;
I O檔案的具體操作
對於乙個磁碟來說,檔案系統是通過檔案目錄從檔名來進行對映,從而得到了檔案的空間分配,比如說ms dos將檔名對映為乙個數,這個數顯示了檔案訪問表的乙個條目,這個條目說明了哪些磁碟塊被分配給檔案。在unix當中將檔名對映為inode號,相應的inode包含了空間分配資訊 從檔名到磁碟控制器的連線是如何...
Hive 分割槽的具體操作
建立乙個一級分割槽 create table if not exists day part uid int,uname string partitioned by year int row format delimited fields terminated by t load入資料 load da...
SQL優化的具體操作
1 在表中建立索引,優先考慮where group by使用到的字段。2 盡量避免使用select 返回無用的字段會降低查詢效率。如下 select from t 優化方式 使用具體的字段代替 只返回使用到的字段。3 盡量避免使用in 和not in,會導致資料庫引擎放棄索引進行全表掃瞄。如下 se...