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.
Related
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");
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 am using the Camera activity to capture the JPEG image. After image is saved and the controll is returned back to my application activity I would like to to determine the captured JPEG image dimensions without loading the whole image into memory via Bitmap object - can it be easily done somehow?
Is there any class, which reads the JPEG header and give me such information? I would like to avoid OOM conditions - but might be it is not a problem to load the whole image into memory - is it?
After knowing the dimensions I would like to use BitmapFactory to scale the image.
Thanks a lot
Kind Regards,
STeN
Perhaps a work-around (see 2nd approach) by setting the quality?
bmp.compress(CompressFormat.JPEG, 75,
pfos);
You would have to do a trial run to see what size the quality gets you though...
*The first approach creates a log file to get the width and height but not sure if you wanted the extra step of looking at a log file.
You can use the ExifInterface class to read the image width and height.
I want image being shown in imageview to be selected with particular portion(and only selected portion needs to highlighted and other portion to be semi transparent) and that portion can also be resized as needed or done done by user on touch event.
Now, the selected portion of image is needed to be croped and then show and save that cropped image.
EDIT:
I used Intent to open the image and crop it using intent.putExtra("crop","true");
But while passing intent I want to open image whose URI is already known instead of opening the whole album of image gallery.
Can anyone suggest, how can I open particular URI through intent passing for opening image.
Thanks in advance.
Regarding the last part of your question, if you're on the very latest Gingerbread (2.3.3, API level 10), you can use BitmapRegionDecoder to crop an image.
It's useful because, until this API existed, you had to load the entire image into memory before you could crop. With 5mpix and 8mpix cameras this is usually impossible without subsampling (i.e. the cropped image loses lots of resolution).
UPDATE: Changed my answer after question was edited and more precisely described.
Issue you are facing with has long history, also at SO:
unable to find com.android.camera.CropImage activity in android
One answer has described what you need. Please note that you are using intent that is not part of the official SDK, and you may encounter different kind of issues. Issue I experienced was using crop immediatelly after image was taken by the camera. Also, it is not compatible through different Android versions, so if you get it working for 1.5 maybe it will not work for 2.3. Other useful links:
http://groups.google.com/group/android-developers/browse_thread/thread/2dd647523926192c/569f36b5b28f2661?lnk=gst&q=Crop+image+intent#569f36b5b28f2661
http://groups.google.com/group/android-developers/browse_thread/thread/2dd647523926192c/dcbe5aef29eddad6?lnk=gst&q=Crop+image+intent#dcbe5aef29eddad6
http://groups.google.com/group/android-developers/browse_thread/thread/d7b6a133c164aa17/184bf3b85da2ce58?lnk=gst&q=Crop+image+intent#184bf3b85da2ce58
Check out my answer to this question. It doesn't deal with the touch-to-resize aspect of your question, but handles drawing parts of an image over the original image.
Bottom line is, you don't want to use an ImageView, since that's mainly for displaying a static image with various scaling properties. You're better off using a custom view with an overridden draw() method.
For Cropping image
private void cropImage() {
// Use existing crop activity.
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(capturedImageUri, IMAGE_UNSPECIFIED);
// Specify image size
intent.putExtra("outputX", IMAGE_DIMENSION);
intent.putExtra("outputY", IMAGE_DIMENSION);
// Specify aspect ratio, 1:1
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("scale", true);
intent.putExtra("return-data", true);
// REQUEST_CODE_CROP_PHOTO is an integer tag you defined to
// identify the activity in onActivityResult() when it returns
startActivityForResult(intent, REQ_CODE_CROP_PHOTO);
}
I need a little help with getting my camera to work right.
What I'm trying to do is have the user take a picture that will then be used in another activity as the view's background. It is important not to have any skewing, and ideally the image would fill the entire background with the highest resolution possible.
I've been having a heck of a time trying to get the outputted picture of my camera to be oriented properly and be the same aspect of the display. So I took some time to think of exactly what I needed to do, and I don't think I need the normal saved image at all.
What I came up with is that I need a surface view to display the preview, and an overlay for some text and a capture button. When the user "takes the picture" it should autofocus, and then I need to capture the preview (under the screen overlays) to a bitmap to use in the other activity.
*Should I extend a SurfaceView for my preview and add it to a XML layout that contains the overlays?
*How do I save the SurfaceView's image to a bitmap?
Thanks.
Matt,
One basic question ,and excuse my naivety, wouldnt it just be easier to use the built in camera to the Android through an Intent? It is doable, I've done it before.
Apparently, there is no good way to convert the image format of the preview frames to a jpeg, so I ended up selecting the size for the camera to take by going through each of the camera's supported resolutions and getting the closest match the the screen aspect with the highest resolution.
Because the camera.setRotation method doesn't seem to do anything, I just rotate the image 90 with a matrix before saving it to the card if I am in portrait mode.