Saturday 15 February 2014

Android Camera Landscape Image -



Android Camera Landscape Image -

i'm developing app has surfaceview camera. want take landscape images in both landscape , portrait modes. preview shown okay since used camera.setdisplayorientation(90); in code.

however when take image, displayed rotated. can rotate 1 time again become portrait done. know how take landscape image camera?

this how configured photographic camera parameters

private void configure() { camera.parameters params = camera.getparameters(); // configure image format. rgb_565 mutual format. list<integer> formats = params.getsupportedpictureformats(); if (formats.contains(pixelformat.rgb_565)) params.setpictureformat(pixelformat.rgb_565); else params.setpictureformat(pixelformat.jpeg); // take biggest image size supported hardware /*list<camera.size> sizes = params.getsupportedpicturesizes(); camera.size size = sizes.get(sizes.size()-1); params.setpicturesize(size.width, size.height);*/ params.setpicturesize(constants.image_width, constants.image_height); list<string> flashmodes = params.getsupportedflashmodes(); if (flashmodes.size() > 0) params.setflashmode(camera.parameters.flash_mode_auto); // action mode take pictures of fast moving objects list<string> scenemodes = params.getsupportedscenemodes(); if (scenemodes.contains(camera.parameters.scene_mode_action)) params.setscenemode(camera.parameters.scene_mode_action); else params.setscenemode(camera.parameters.scene_mode_auto); // if take focus_mode_auto remember phone call autofocus() on // photographic camera object before taking image params.setfocusmode(camera.parameters.focus_mode_auto); camera.setparameters(params); }

and take image

private void takepicture() { configure(); camera.autofocus(new camera.autofocuscallback() { @override public void onautofocus(boolean success, photographic camera camera) { camera.takepicture(shuttercallback, picturecallback_raw, picturecallback_jpeg); } }); }

this save image taken camera

picturecallback picturecallback_jpeg = new picturecallback() { public void onpicturetaken(byte[] data, photographic camera camera) { file storagedirectory = camerahelper.getstoragedirectory(); string filename = camerahelper.getstoragefilename(); imagepath = storagedirectory.getpath()+file.separator+filename; file output = new file(storagedirectory, filename); seek { fileoutputstream fos = new fileoutputstream(output); fos.write(data); fos.close(); imagecapturedstate=true; } grab (filenotfoundexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); } } };

this photographic camera preview when take picture

this how displayed 1 time saved (the image in preview rotated 90 degrees.)

so see, can rotate image, become portrait 1 time have done it. how can save landscape image without ratating? give thanks you!

android camera

No comments:

Post a Comment