android - How to get full size image from custom front camera with full screen length -


i making android app using front camera of device , has take picture in portrait form want save picture in same result showing in preview when take photo , save bitmap bitmap seems awkward increases size in length. seems doing wrong squeezing camera picture while saving.

i have searched many links , came know have set aspect ratio. did not it. want in coding because have complete app , working best on samsung grand , s4 not working on lg g3 , .

here doing surfaceview class . sharing surface view class know there wrong here , rest of other classes easy . camerapreview.java

public class camerapreview extends surfaceview implements surfaceholder.callback {  private camera camera; public static  surfaceholder holder; private activity activity;   public camerapreview(context context, attributeset attrs, activity activity) {     super(context, attrs);  }  public camerapreview(context context, attributeset attrs) {     super(context, attrs); }  public camerapreview(context context) {     super(context); }  public void init(camera camera,activity activity) {     this.camera = camera;     this.activity = activity;     initsurfaceholder(); }  @suppresswarnings("deprecation") // needed < 3.0 private void initsurfaceholder() {     holder = getholder();     holder.addcallback(this);     holder.settype(surfaceholder.surface_type_push_buffers);  }  @override public void surfacecreated(surfaceholder holder) {     initcamera(holder); }  private void initcamera(surfaceholder holder) {     try {         camera.parameters parameters = camera.getparameters();         list<camera.size> previewsizes = parameters.getsupportedpreviewsizes();         camera.size previewsize = previewsizes.get(0); //480h x 720w         for(int = 0 ; i<=6;i++){               log.v("preview sizes"+previewsizes.get(i));             camera.size previewsizedemo = previewsizes.get(i);             log.v("preview size are" +previewsizedemo.width+""+ previewsizedemo.height+"of"+i);             camera.size previewsizedemo1 = previewsizes.get(1);             log.v("preview size of 0 is" +previewsizedemo1.width+""+ previewsizedemo1.height);         }          parameters.setpreviewsize(previewsize.width,previewsize.height);       parameters.setzoom(camera.parameters.focus_distance_optimal_index);          camera.setparameters(parameters);         requestlayout();         camera.setpreviewdisplay(holder);         camera.startpreview();        } catch (exception e) {         log.d("error setting camera preview", e);     } }  @override public void surfacechanged(surfaceholder mholder, int format, int width, int height) {      camera.parameters parameters = camera.getparameters();     list<camera.size> previewsizes = parameters.getsupportedpreviewsizes();      camera.size previewsize = previewsizes.get(0); //480h x 720w      parameters.setpreviewsize(previewsize.width,previewsize.height);          requestlayout();      camera.setparameters(parameters);      display display = ((windowmanager)activity.getsystemservice(context.window_service)).getdefaultdisplay();     if(display.getrotation() == surface.rotation_0) {         camera.setdisplayorientation(90);         parameters.setpreviewsize(previewsize.width, previewsize.height);     } else if(display.getrotation() == surface.rotation_270) {         camera.setdisplayorientation(180);         parameters.setpreviewsize(previewsize.width, previewsize.height);     }      camera.startpreview();      }// end surfacechanged      @override public void surfacedestroyed(surfaceholder holder) {     log.e("tabact"+"surfacedestroyed()");     camera.stoppreview();     camera.setpreviewcallback(null);     camera.release();     camera = null;      this.getholder().removecallback(this);   }  private camera.size getoptimalpreviewsize(list<camera.size> sizes, int w, int h) {     final double aspect_tolerance = 0.1;     double targetratio=(double)h / w;      if (sizes == null) return null;      camera.size optimalsize = null;     double mindiff = double.max_value;      int targetheight = h;      (camera.size size : sizes) {         double ratio = (double) size.width / size.height;         if (math.abs(ratio - targetratio) > aspect_tolerance) continue;         if (math.abs(size.height - targetheight) < mindiff) {             optimalsize = size;             mindiff = math.abs(size.height - targetheight);         }     }      if (optimalsize == null) {         mindiff = double.max_value;         (camera.size size : sizes) {             if (math.abs(size.height - targetheight) < mindiff) {                 optimalsize = size;                 mindiff = math.abs(size.height - targetheight);             }         }     }     return optimalsize; } 

keep in mind using front facing camera only. please me in how can take full length image front camera out getting inverted other angle portrait.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -