我正在捕捉图像并将其设置为图像视图.
public void captureImage() {
Intent intentCamera = new Intent("android.media.action.IMAGE_CAPTURE");
File filePhoto = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
imageUri = Uri.fromFile(filePhoto);
MyApplicationGlobal.imageUri = imageUri.getPath();
intentCamera.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intentCamera, TAKE_PICTURE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intentFromCamera) {
super.onActivityResult(requestCode, resultCode, intentFromCamera);
if (resultCode == RESULT_OK && requestCode == TAKE_PICTURE) {
if (intentFromCamera != null) {
Bundle extras = intentFromCamera.getExtras();
if (extras.containsKey("data")) {
bitmap = (Bitmap) extras.get("data");
}
else {
bitmap = getBitmapFromUri();
}
}
else {
bitmap = getBitmapFromUri();
}
// …Run Code Online (Sandbox Code Playgroud) 是否有一种标准方式来调用对话框,选择从相机中选择图像还是从图库中获取(如内置电话簿或Skype)?
我已经看了这个,但代码打开了画廊,没有建议从相机中选择它.
设备:三星Galaxy Tab
Android:2.3.3
我有一堆图像,其中一些图像必须旋转.
样品:

我想将此图像逆时针旋转90°.
我用Google搜索知道如何旋转图像并找到许多链接和SO线程.但是如何确定图像是否需要旋转?Picasa具有自动旋转功能.我想要有类似的功能.
任何指针都对我很有帮助.
我找到了一个链接,但它与Android有关.
我正从横向模式的相机保存图像.所以它以横向模式保存,然后我将横向应用于横向模式.我想旋转该图像,然后保存.例如,如果我有这个

我想顺时针旋转90度,然后将其保存到sdcard:

这是如何实现的?
在我的应用程序中,我提示用户捕获图像.用户相机活动从buttonClick开始,用户可以选择使用相机捕获图像.
此图像保存在用户手机上.然后将图像上传到firebase存储,一切正常.使用Samsung Note 8的一个用户的反馈是,当以纵向模式捕获图像时,他稍后在应用程序中以横向模式显示它.
我查看了firebase存储,发现图像以LANDSCAPE模式保存在存储中,即使用户以纵向模式捕获图像.
我想我必须将元数据传递给以纵向模式捕获图像的jpeg文件,以便firebase知道它实际上是纵向模式.
这是捕获图像的代码:
private void takePhoto() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
// Error occurred while creating the File
}
if (photoFile != null) {
imageUri = FileProvider.getUriForFile(this, "com.example.android.fileprovider", photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是CreateImageFile的方法:
public File createImageFile() throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyy.MM.dd_HH:mm:ss").format(new Date());
String …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我添加了图像上传功能,它可以很好地处理除了摄像机图像之外的所有图像,每当我从图库中浏览摄像机图像和纵向图像旋转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)