我制作了一个自定义相机应用程序,并在相机点击后在图像视图中显示我的图像。但是在这里我面临一个问题,即我捕获的图像总是以改变方向设置。
即,如果我在将相机作为人像时拍摄照片,它不会将图像设置为人像,它会改变方向。
这是相机点击代码:-
@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());
}
}
};