Android Photo Size and Resolution - android

Pardon the basic question, but I don't quite get how to work with Android Camera class and Parameters.
What I am trying to use Android API to take a picture that will display in a fixed area of my activity. Its about 3inches by 2inches on screen.
Lets say I know that I want a picture that displays in a 360x220px area? I am talking about on the activity size. So I how do I match this up to the accepted picture size of the camera. I mean I see it supports 480x800 and 800x480. This seems to actually be the closest size but its hard to find one thats really matches the display area I have?
So I don't know where to specify that size of picture to take that will look good in that area. Do I specify this during preview? I mean I guess what I thought I could do is preview in same size somehow as the display area I wanted to finally show the picture in? Also how to save it off properly. Should I just pick closest, save and then try to scale? Are there any libraries I should be using for this beside Android SDK?
Sorry about rant. I just have a specific size(I can change it somewhat but I have to fix it and I don't think its 480x800) and I just want to take a picture that will fit in that area, save it load and display it there? How do I do this? I would like a preview that does not take up a bigger area, and a picture that looks just like what is previewed.
Whats happening now is pictures displaying that looked zoomed etc or two small, too big everything but what I want to display.

Related

android capture portion of camera view

I come up to you because I have a big problem.
I would like to capture only a portion of the camera view.
I basically want something like this :
I tried to do the same with AndroidStudio, by adding a picture on the screen, here is the result :
It's ugly but it was just to try.
You basically need to put your face into the transparent area, and then click on "take picture". I would like the camera to not take the black part.
How is it possible ? Is it possible to create a kind of mask for the camera ?
I have in mind that in this case, I'll need to take the entire picture and scale it correctly by software. But then, I have to do it differently for every screen sizes. It looks incredibly difficult.
Instead, is it possible to directly modify the cameraView (SurfaceView, or SurfaceHolder) so that I won't need the image, and the picture will automatically fit the "mask" because it's actually the only thing the camera see.
Have you got some clues ?
thank you very much !
The camera sees whatever enters its lens. You cannot "make" it see only a certain shape out of its normal rectangle (unless you tape some black paper over it :)). The cropping is always done after the picture is taken. The SurfaceView and SurfaceHolder are just tools to help you present the picture (which can be already modified, if you want it to) on the phone screen.
No you cannot mask camera capture. You can apply the mask to result. Note that often you get still picture at a resolution much higher than what you use for preview. And preview resolution is not the same as screen resolution (which you should use to put the black mask on the screen). In such case, your postprocessing mask should match the picture resolution and not the preview resolution.

How do I take a picture of what fits inside a square in android?

I have to make my app capable of taking pictures of only whatever it fits a squared frame that is superimposed on the preview.
The idea is: the client wants the app to send pictures of 600x600px tops. To avoid cropping important parts of the picture, he decided to put this superimposed squared frame (similar to the one in QR-reading apps) and to crop out everything out of said frame.
To do this I need two things.
1) How do I set the frame dimensions for multiple screens while getting the output within the required dimensions?
2) Once the frame is up and running... how do I crop out the rest of the picture?
Thanks in advance.
Update
What I want to do is something similar to what is explained here http://www.londatiga.net/featured-articles/how-to-select-and-crop-image-on-android/
Thing is:
This how-to checks if there's an image-cropper app installed, it
doesn't do the cropping by itself (or so I understand, maybe I'm
wrong?).
The frame seems to be 200x200... px? dp? Would that frame take up the
same portion of screen on xhdpi screens that on ldpi screens?
What's the size of the resulting image? Can I decide it somehow?

Android background bitmap crop

I have a background png in my Android application. I would like to support lots of displays, but I have this one obstacle - many displays have many resolutions and many ratios. I would like to make sure my background is displayed properly and make it more ellegant, than just creating 10+ cropped png files in Photoshop.
My idea would be - a fairly large picture imported in the project. The app would find out screen dimensions and simply say starting points(x,y) and ending points, that would "crop" the picture and display it without any deformations.
Is there a way of doing it?
I think bitmap.createBitmap() is the method your looking after. The method simply lets you cut out a defined portion of the bitmap.

Cropping large background image

I have two situations/projects where I have to use a large bitmap as background activity.
The first project ports a WP7 application to Android! The WP7 app is using a panorama control with a bitmap as large as 3 screens. I would like to reuse the large bitmap similar in a way that I use the left part for the first activity, the middle part for the second activity and the right part for the third activity. In other words I would like to define which part to crop.
In the second project we try to develop an app which should run on various screen sizes (including tablet), the app should also use a background image. Is it a good idea to provide only one picture with a quadratic size (as long as the largest screen width) and use this picture through every resolution and just crop the background image depending on the actual size of the display?
Is it possible to crop pictures on Android?
Is it possible to define the part of the picture which is kept?
Is it possible to use this croped pictures as background image or may I encounter performance penalties?
What do you think of this technique? Is it a good idea?
Thanks for your help!
answering your questions:
yes it is possible to crop pictures in Android (I've done so)
you can define wich part of the picture is shown in each activity
with a canvas and only drawing the rect that corresponds to the part
of the image that you want to display (eventough I wouldnt suggest
the approach of having diferent activities with the "same" content)
yes, you can use cropped pictures as background image for whatever
you want. Once you cropped the image use that bitmap and save it in
the device and then you might use it as you wish, and eventought is not recommended to have the whole image as background you can do so.
I suggest that you use a SurfaceView since you will be able to move it (the image) all around the screen without having to create a new activity. Here is a good tutorial to SurfaceView Playing with graphics in Android – Part I and this approach will also work with Tablets.

Saving a camera's preview to a bitmap

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.

Categories

Resources