I am making an application where I need to take a photo and then crop a 100x100 area from it. Right now I am making an intent call for taking a picture and then I create a CropActivity that will crop it.
I was wondering if default photo application could be set crop taken picture and show a border on screen to identify an area which is supposed to be cropped before taking the picture.
Maybe with some extras? I dont know. I search ong enought, but didnt find anything to do this in one step WITH preview.
(please do not post solutions, how to crop image separately and without a preview, I already know)
I was wondering if default photo application could be set crop taken picture and show a border on screen to identify an area which is supposed to be cropped
There are well over 1 billion Android devices, spread across over a thousand device models. Those have hundreds of "default photo applications", as a mix of pre-installed apps and other camera apps that users installed and made be their default.
None have to support any sort of crop-related extras.
You can save path of image(i.e. Uri) in a string then putExtra this with your intent as:
String mUri = "android.media.whatever";
Intent mIntent.putExtra("imgUri", mUri);
and then in receiver side you can get the image using:
Bitmap img = BitmapFactory.decodeFile(getIntent().getStringExtra("imgUri");
Related
in my app I capture a photo using intent MediaStore.ACTION_IMAGE_CAPTURE and I save image into external storage that is private to my app. I also save the path to taken picture.
In next step I would like to crop 3 pictures from this photo but I cannot figure out how to do it. I found this article Crop an Image by passing the image file path in Android but the answer uses com.android.camera.action.CROP, which is often not supported. I would like to crop it like this
Bitmap bmp=BitmapFactory.decodeResource(getResources(), R.drawable.xyz);
resizedbitmap1=Bitmap.createBitmap(bmp, 0,0,yourwidth, yourheight);
but I need to crop picture according to user selection. Can anyone help me with this? I am pretty stuck here.
So I ended up using some third party library for cropping pictures. I recommend you to do the same. You will find plenty of them on github, choose according to your preferences.
I succesfully made this simple app of where you can either choose and image from gallery or take a picture: Pick Image From Gallery Or Camera In Android Studio Programmatically. But for my purpose, where the selected image needs to serve as a profile image, I want the image to be square.
Also, some photos that are selected from gallery are rotated (Not to mention they are rectangled)
Where do I go from here in order to make user crop and rotate the image before uploading it? I want the final result to be a square image with the correct rotation.
In terms of cropping the image, there are many image cropping libraries for Android for you to choose from.
It is possible that one of those will also allow the user to rotate the image. If not, you will need to handle that yourself.
If you only need to allow the user to rotate the image a few ways (e.g., portrait and landscape), you could use a Switch or Spinner to allow the user to choose a rotation, then rotate the ImageView to show them what it looks like. Once they choose a rotation to use, you can use a Matrix to rotate the Bitmap. Ideally, you would rotate the image after cropping, as photos are large and you may run out of memory trying to rotate a photo.
I have a surface view, 3 buttons one each for capture, use(invisible) and retake(invisible). I am using the Camera to take a picture. On image capture, use and retake buttons become visible and capture goes invisible. How to save the image in SD card on clicking the use button. Can anyone help with any example code. ??
Inshort I dont want to skip retake and skip option after capturing a pic in android !!! No use of intents !! only using android camera
How to skip 'retake and use' option after captureing photo from camera
Here is a nice tutorial on taking picture in Android: http://www.vogella.com/tutorials/AndroidCamera/article.html
In the nutshell, after you call Camera.takePicture(), a onPictureTaken() callback is called with jpeg image in byte[]. You convert this image to bitmap (preferably scaled down) for display, and you can write this byte[] as is to a .jpg file if the user likes it.
Is it possible to programmatically take a picture in full/high resolution? I use the camera preview and surface with some custom overlay content. The problem is that the takePhoto function returns data only in preview size low resolutions.
Even if I check the getSupportedPictureSizes the resolutions that are listed are far from the 5Mpix that is the max supported resolution by the system camera. So the question is can I take a photo in max resolution and use custom camera preview or I have to call the system camera Intent to have a full res photo?
Yes you can, you should setPictureSize(), see https://github.com/alexcohn/JBcamera for example.
PS Thanks, Benjamin, for drawing my attention back to this question. if I understand correctly, the author was upset with the resolution of data array returned from IMAGE_CAPTURE intent. But this is only the thumbnail; the actual hi-rez imagis writn to file. You can find this Jpeg file and load it into your app, in onActivityResult()
By default I think it is set to a low resolution. To change this call MediaStore.EXTRA_OUTPUT in your intent. See here for more detail:
http://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE
I have called an intent by passing action "android.media.action.IMAGE_CAPTURE"
i.e. intent.setAction("android.media.action.IMAGE_CAPTURE");and the image I get is small size.and i want to get Full Sized image of 730X1115 size.How can I get that.
Have you tried using
Intent cameraIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
Though both your code and this redirects you to the Native Camera there is been much difference with the quality considerations. May be you should give it a try.
I have scaled that image by giving the dimensions of the border in which it gets fit.