Drawing a Camera Preview in a certain area of the screen

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Drawing a Camera Preview in a certain area of the screen

Postby kikoso » Tue Nov 17, 2009 4:53 pm

Hello all,

I have been playing with Android for a couple of months, so I'm still
kindof newbie on this. I've looking for previous questions like mine,
but I was unable to find any proper solution. So here goes my
question:

I'm trying to draw a Camera Preview in a certain part of the screen
(for instance, square upper-left). So what I suppose I should do is
the following:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. //My main activity
  3.  
  4.  
  5.  
  6. //Object preview, which extends from SurfaceView implements
  7.  
  8. SurfaceHolder.Callback
  9.  
  10. Preview camPreview;
  11.  
  12.  
  13.  
  14. [...]
  15.  
  16.  
  17.  
  18. setContentView(camPreview); //set preview as activity content
Parsed in 0.029 seconds, using GeSHi 1.0.8.4


And on the Preview Class I have the following lines:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public void surfaceCreated(SurfaceHolder holder) {
  3.  
  4.        // The Surface has been created, acquire the camera and tell
  5.  
  6.        // to draw.
  7.  
  8.        mCamera = Camera.open();
  9.  
  10.        try {
  11.  
  12.        //Trying to set up the PreviewSize, to embed it into the upper-
  13.  
  14. left square
  15.  
  16.                Camera.Parameters parameters = mCamera.getParameters();
  17.  
  18.                parameters.setPreviewSize(50, 50);
  19.  
  20.                mCamera.setParameters(parameters);
  21.  
  22.                mCamera.setPreviewDisplay(holder);
  23.  
  24.        } catch (IOException e) {
  25.  
  26.                // TODO Auto-generated catch block
  27.  
  28.                e.printStackTrace();
  29.  
  30.        }
  31.  
  32. }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


The preview is still occuping all the screen, so I bet I
missunderstood something in the manuals :S. For the first touch with
Android I found the views / layouts / organizational concepts pretty
confusing, though.

Does anyone have any suggestion about what I can check, in order to
achieve it?

Thank you in advance, and regards,

Enrique
kikoso
Freshman
Freshman
 
Posts: 6
Joined: Thu Nov 12, 2009 11:41 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests