相关疑难解决方法(0)

确保照片以与拍摄时相同的方向保存?

由于某种原因,我的相机应用程序保存所有旋转90度的照片(图片只在横向模式下用相机拍摄时看起来正确)我相信照片应该自动旋转照片但我读到三星设备有问题(我还没有能够在另一个品牌测试它,所以我不知道是否是这种情况).这是我的代码:

   public void onPictureTaken(byte[] data, Camera camera) {
      // Generate file name
      FileOutputStream outStream = null;
      outStream = new FileOutputStream(filePath);
      outStream.write(data);
      outStream.close();
Run Code Online (Sandbox Code Playgroud)

我认为可以通过检查方向和旋转字节数组来修复它,但是必须有一种更直接的方法来处理它,因为处理字节数组很麻烦.如何确保照片的保存方式与拍摄方向相符?

java camera android photo bytearray

9
推荐指数
1
解决办法
1204
查看次数

如何设置相机图像方向?

在我的应用程序中,我添加了图像上传功能,它可以很好地处理除了摄像机图像之外的所有图像,每当我从图库中浏览摄像机图像和纵向图像旋转90度时.以下是我的代码片段..有人可以帮我吗?我遵循了很多教程但是所有这些教程在kikat中工作得很好..但是当同一个教程不适用于ics,软糖等时..

public class MainActivity extends Activity {
private Button browse;
private String selectedImagePath="";
private ImageView img;

private TextView messageText;

private static int SELECT_PICTURE = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    img = (ImageView)findViewById(R.id.imagevw);
    browse=(Button)findViewById(R.id.browseimg);
    messageText  = (TextView)findViewById(R.id.messageText);
    browse.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
             Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE);
        }
    });
}
 @Override
   public void onActivityResult(int requestCode, int resultCode, Intent data) {
       if (resultCode == …
Run Code Online (Sandbox Code Playgroud)

android android-camera android-camera-intent

3
推荐指数
1
解决办法
1万
查看次数

使用Android Camera API时,快照照片的方向始终为未定义

我使用相机api,拍摄的照片总是旋转90度,我想旋转它.

首先,我想知道图片的方向,这一点我卡住了.我总是以两种方式获得UNDEFINDED方向.

这是代码:

    @Override
        public void onPictureTaken(byte[] data, Camera camera) {


            //Bitmap Options for lowering quality the bitmap to save memory
            Options options = new BitmapFactory.Options();
            options.inSampleSize = 4;
            options.inPreferredConfig = Bitmap.Config.RGB_565;

            //Make the bitmap
            Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options);

            //Making the path, the root will be fine for tests
            String path = Environment.getExternalStorageDirectory().toString();

            //output stream
            OutputStream outputStream = null;
            //Making the file as a jpg
            File file = new File(path, "tmp_pic" + ".jpg"); // the File to …
Run Code Online (Sandbox Code Playgroud)

camera android exif orientation android-camera

2
推荐指数
1
解决办法
4879
查看次数

如何在没有ExifInterface的情况下确定图片的方向?

我将图像加载到a中bitmap并且需要知道所拍摄图像的方向(来自相机)以正确显示它.使用以下代码的方法工作得很好(自API级别5以来),但该怎么办android:minSdkVersion="4"?还有另外一种方法吗?

ExifInterface exif = new ExifInterface(SourceFileName);     //Since API Level 5
String exifOrientation = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
Run Code Online (Sandbox Code Playgroud)

android exif orientation

0
推荐指数
1
解决办法
1万
查看次数