Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Perhaps this link can help you.</p> <p><a href="http://adblogcat.com/a-camera-preview-with-a-bounding-box-like-google-goggles/" rel="nofollow">http://adblogcat.com/a-camera-preview-with-a-bounding-box-like-google-goggles/</a></p> <p>Here is the onSurfaceChange method which sets the right orientation</p> <pre><code>public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { //Log.i(TAG, "Preview: surfaceChanged() - size now " + w + "x" + h); // Now that the size is known, set up the camera parameters and begin // the preview. try { mParameters = mCamera.getParameters(); mParameters.set("orientation","landscape"); for (Integer i : mParameters.getSupportedPreviewFormats()) { //Log.i(TAG, "supported preview format: " + i); } List&lt;Size&gt; sizes = mParameters.getSupportedPreviewSizes(); for (Size size : sizes) { //Log.i(TAG, "supported preview size: " + size.width + "x" + size.height); } mCamera.setParameters(mParameters); // apply the changes } catch (Exception e) { // older phone - doesn't support these calls } //updateBufferSize(); // then use them to calculate Size p = mCamera.getParameters().getPreviewSize(); //Log.i(TAG, "Preview: checking it was set: " + p.width + "x" + p.height); // DEBUG mCamera.startPreview(); } public Parameters getCameraParameters(){ return mCamera.getParameters(); } </code></pre> <p>The article sets the parameters to landscape. I see you do not have this in your code.</p> <p>Also, for saving images I see two methods:</p> <pre><code>private boolean savePhoto(Bitmap bm) { FileOutputStream image = null; try { image = new FileOutputStream(mLocation); } catch (FileNotFoundException e) { e.printStackTrace(); } bm.compress(CompressFormat.JPEG, 100, image); if (bm != null) { int h = bm.getHeight(); int w = bm.getWidth(); //Log.i(TAG, "savePhoto(): Bitmap WxH is " + w + "x" + h); } else { //Log.i(TAG, "savePhoto(): Bitmap is null.."); return false; } return true; </code></pre> <p>}</p> <p>and</p> <pre><code>public Bitmap getPic(int x, int y, int width, int height) { System.gc(); Bitmap b = null; Size s = mParameters.getPreviewSize(); YuvImage yuvimage = new YuvImage(mBuffer, ImageFormat.NV21, s.width, s.height, null); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); yuvimage.compressToJpeg(new Rect(x, y, width, height), 100, outStream); // make JPG b = BitmapFactory.decodeByteArray(outStream.toByteArray(), 0, outStream.size()); if (b != null) { //Log.i(TAG, "getPic() WxH:" + b.getWidth() + "x" + b.getHeight()); } else { //Log.i(TAG, "getPic(): Bitmap is null.."); } yuvimage = null; outStream = null; System.gc(); return b; </code></pre> <p>}</p> <p>And you need to use android 2.2 </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload