i need to capture image from required portion of the screen.
capture image from camera.
at that time other screen content as it is.
how is this possible?
i need to capture image from required portion of the screen.
capture image from camera.
at that time other screen content as it is.
how is this possible?
If the part of the screen is actually a view, you can capture only this view. Like this:
If you want to capture only small portion of a view, you have to calculate rectangle of this side. Then:
It's only a pseudocode, but I hope you get the idea. Simply translate and draw only the part you need.
I use the CameraPreview in ApiDemos application and edit it as your requirement.
First, copy the code of the Preview class into a new class file in the same package so that it is public and you can declare it in the xml layout file. Remember to add one more constructor as below:
Sample layout file with sample width and height:
In the onCreate() method of the CameraPreview activity, change the setContentView part as followed:
I already created like that kind of Camera. What I did is, I covered the other area of the camera with an image, and cut the center part of the image and save it as png file, to make the center transparent.
You will set background image of your frame(camera preview) with that image. So that it will look like the camera is only that portion that is transparent or the circle.
I used this tutorial to open,create preview,and take picture from camera device http://developer.android.com/guide/topics/media/camera.html
in this part(u can see this in the link I provide above)
follow this tutorial on how to crop the image to circle Cropping circular area from bitmap in Android
try to use Surface View for creating dynamic camera view and set in your required portion.
following code try
variables set Class level (Global)
Following code in onCreate() method
Following code put after onCreate() in your class.
in AndroidManifest.xml give user-permissions.
and also not forgot ( implements SurfaceHolder.Callback ) to the class.
you can use surface view.after capture image u can get in bitmap and draw canvas also
http://developer.android.com/reference/android/view/View.html#onDraw(android.graphics.Canvas)
http://developer.android.com/reference/android/view/SurfaceView.html#setZOrderMediaOverlay(boolean)
use TextureView for preview,set layout_width and layout_height what ever you want. here is the code:
and xml file: