Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Android
how can i customize cameras height width programmatically
Suzzane Pinto
Ranch Hand
Posts: 214
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi,,
i want to change the hieght width of camera as per my need...
how can i achieve that programmatically???
found no guid link...any idea to startup??
Tim Moores
Saloon Keeper
Posts: 7585
176
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What do you mean by that? The camera is a hardware device that is not amenable to changes. You can influence the size of the preview and the size of the final image, though.
Suzzane Pinto
Ranch Hand
Posts: 214
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
yes....i exactly want to do what you said.....sory for putting a wrong question.....i want to change the height and width of preview
how do i do that anyway??
Tim Moores
Saloon Keeper
Posts: 7585
176
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The preview size can be set in the onSurfaceChanged method of your SurfaceHolder.Callback. That's step 3 in this tutorial:
http://code.google.com/p/openmobster/wiki/CameraTutorial
Suzzane Pinto
Ranch Hand
Posts: 214
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i have tried this code
package fortyonepost.com.pwop;//Created by DimasTheDriver Mar/2011 - Part of "Android: take a picture without displaying a preview" post. Available at: http://www.41post.com/?p=3794 . import java.io.FileNotFoundException; import java.io.IOException; import java.io.OutputStream; import java.util.List; import android.app.Activity; import android.content.ContentValues; import android.content.pm.ActivityInfo; import android.graphics.PixelFormat; import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.hardware.CameraDevice; import android.hardware.Camera.AutoFocusCallback; import android.hardware.Camera.PictureCallback; import android.hardware.Camera.ShutterCallback; import android.hardware.Camera.Size; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore.Images.Media; import android.view.LayoutInflater; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; public class TakePicture extends Activity implements SurfaceHolder.Callback{ Camera camera; SurfaceView surfaceView; SurfaceHolder surfaceHolder; boolean previewing = false; LayoutInflater controlInflater = null; Size mPreviewSize; Button buttonTakePicture; TextView prompt; final int RESULT_SAVEIMAGE = 0; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); getWindow().setFormat(PixelFormat.UNKNOWN); surfaceView = (SurfaceView)findViewById(R.id.camerapreview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); surfaceHolder.setFixedSize(1800, 1200); System.out.println("hello"); controlInflater = LayoutInflater.from(getBaseContext()); View viewControl = controlInflater.inflate(R.layout.control, null); LayoutParams layoutParamsControl = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); this.addContentView(viewControl, layoutParamsControl); buttonTakePicture = (Button)findViewById(R.id.takepicture); buttonTakePicture.setOnClickListener(new Button.OnClickListener(){ public void onClick(View arg0) { // TODO Auto-generated method stub camera.takePicture(myShutterCallback, myPictureCallback_RAW, myPictureCallback_JPG); }}); LinearLayout layoutBackground = (LinearLayout)findViewById(R.id.background); layoutBackground.setOnClickListener(new LinearLayout.OnClickListener(){ public void onClick(View arg0) { // TODO Auto-generated method stub buttonTakePicture.setEnabled(false); camera.autoFocus(myAutoFocusCallback); }}); prompt = (TextView)findViewById(R.id.prompt); } AutoFocusCallback myAutoFocusCallback = new AutoFocusCallback(){ public void onAutoFocus(boolean arg0, Camera arg1) { // TODO Auto-generated method stub buttonTakePicture.setEnabled(true); }}; ShutterCallback myShutterCallback = new ShutterCallback(){ public void onShutter() { // TODO Auto-generated method stub }}; PictureCallback myPictureCallback_RAW = new PictureCallback(){ public void onPictureTaken(byte[] arg0, Camera arg1) { // TODO Auto-generated method stub }}; PictureCallback myPictureCallback_JPG = new PictureCallback(){ public void onPictureTaken(byte[] arg0, Camera arg1) { // TODO Auto-generated method stub /*Bitmap bitmapPicture = BitmapFactory.decodeByteArray(arg0, 0, arg0.length); */ Uri uriTarget = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, new ContentValues()); OutputStream imageFileOS; try { imageFileOS = getContentResolver().openOutputStream(uriTarget); imageFileOS.write(arg0); imageFileOS.flush(); imageFileOS.close(); prompt.setText("Image saved: " + uriTarget.toString()); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } camera.startPreview(); //camera.startFaceDetection(); }}; public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Camera.Parameters params = camera.getParameters(); List<Camera.Size> sizes = params.getSupportedPreviewSizes(); int mFrameWidth = 1800; int mFrameHeight =1200; params.setPreviewSize(mFrameWidth, mFrameHeight); ; // TODO Auto-generated method stub if(previewing){ //camera.stopFaceDetection(); camera.stopPreview(); previewing = false; } if (camera != null){ try { camera.setPreviewDisplay(surfaceHolder); camera.startPreview(); // prompt.setText(String.valueOf( // "Max Face: " + camera.getParameters().getMaxNumDetectedFaces())); //camera.startFaceDetection(); previewing = true; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public void surfaceCreated(SurfaceHolder holder) { // TODO Auto-generated method stub camera = Camera.open(); //getSupportedPreviewSizes(); surfaceHolder.setFixedSize(1800, 1200); // surfaceHolder.setPreviewSize(1800, 1200); // camera.setFaceDetectionListener(faceDetectionListener); } public void surfaceDestroyed(SurfaceHolder holder) { // TODO Auto-generated method stub // camera.stopFaceDetection(); camera.stopPreview(); camera.release(); camera = null; previewing = false; } }
it can apture image but the resolution is not changed.....which i have set in my code....it saves as default only
Swastik Dey
Bartender
Posts: 2270
20
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
As per my suggestion, it would be better to use MediaStore.ACTION_IMAGE_CAPTURE intent, and scale the final image.
Swastik
You didn't tell me he was so big. Unlike this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Readonly unmodifiable collection
Clipping an image as it is dragged
question about image size
Printing from android
How to select JButton?
More...