1
我製作了自定義相機應用程序,並在相機單擊後在圖像視圖中顯示了我的圖像。但在這裏,我面臨着一個問題,即我拍攝的圖像總是以改變的方向設置。位圖方向更改
即即使在將相機作爲人像拍攝時,如果我拍攝圖像,也不會將圖像設置爲人像,它會更改方向。
下面是攝像頭點擊代碼: -
@Override
public void onPictureTaken(byte[] data, Camera camera) {
//here we write the code for saving the picture onto the sdCard
File pictureFileDir = getDir();
//to check whether directory exists or not!!
if (!pictureFileDir.exists() && !pictureFileDir.mkdirs()) {
//Log.d(Constants.DEBUG_TAG, "Can't create directory to save image.");
Toast.makeText(Irant_Custom_cameraApplication.this, "Can't create directory to save image.",
Toast.LENGTH_LONG).show();
return;
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyymmddhhmmss");
String date = dateFormat.format(new Date());
photo_file="Picture_"+date+".jpg";
photo_FileName = pictureFileDir.getPath()+File.separator+photo_file;
picture_file = new File(photo_FileName);
FileOutputStream outStream = null;
try{
Toast.makeText(getApplicationContext(), "Image captured!", Toast.LENGTH_LONG).show();
outStream = new FileOutputStream(picture_file);
outStream.write(data);
outStream.close();
String imgpath = photo_file;
System.out.println("Path for the image*********************"+photo_file);
SignupDetails.imagePath=imgpath;
}
catch (Exception e) {
Log.d("Image save error :", e.getMessage());
}
}
};