I'm using an HTC Hero with the 1.5 cupcake firmware. I just tried different options to get it working, and this works..
On 9 Dec., 11:58, Wu-cheng Li (李務誠) <[email protected]> wrote: > This is really strange. Which phone and release are you running on? I don't > know any phone that supports JPEG preview frame. > > On Wed, Dec 9, 2009 at 12:25 AM, kaloer <[email protected]> wrote: > > It works now. Should simply set the parameters.setPreviewFormat(); to > > PixelFormat.JPEG. > > > On 5 Dec., 13:05, kaloer <[email protected]> wrote: > > > I have a screenshot of the flicker here:http://tinypic.com/r/35003lv/6 > > > > On 5 Dec., 12:59, kaloer <[email protected]> wrote: > > > > > Hi, > > > > > I have an Dialog with a custom view. This view has a SurfaceView which > > > > shows a camera preview. However, the preview is very flickering. > > > > > The taken photo does not contain flicker. It looks as it should. > > > > > Why does the preview flicker? (The camera does work :-) ) > > > > > This is my custom view: > > > > --------- > > > > > public class CameraView extends LinearLayout implements > > > > SurfaceHolder.Callback, OnClickListener, PictureCallback { > > > > > private SurfaceView surfView; > > > > private SurfaceHolder previewHolder; > > > > private Camera camera; > > > > OnProfilePictureTakenListener onProfilePictureTakenListener = > > null; > > > > > public CameraView(Context context) { > > > > super(context); > > > > setOnClickListener(this); > > > > surfView = new SurfaceView(getContext()); > > > > addView(surfView); > > > > previewHolder = surfView.getHolder(); > > > > previewHolder.addCallback(this); > > > previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); > > > > } > > > > > @Override > > > > public void surfaceChanged(SurfaceHolder holder, int format, > > int > > > > width, > > > > int height) { > > > > Camera.Parameters parameters = camera.getParameters(); > > > > parameters.setPreviewSize(width, height); > > > > parameters.setPictureFormat(PixelFormat.JPEG); > > > > camera.setParameters(parameters); > > > > camera.startPreview(); > > > > } > > > > > @Override > > > > public void surfaceCreated(SurfaceHolder holder) { > > > > camera = Camera.open(); > > > > try { > > > > camera.setPreviewDisplay(previewHolder); > > > > } catch(Throwable t) { > > > > Log.e("surfaceCallback", "Exception", t); > > > > Toast.makeText(getContext(), t.getMessage(), > > Toast.LENGTH_LONG).show > > > > (); > > > > } > > > > } > > > > > @Override > > > > public void surfaceDestroyed(SurfaceHolder holder) { > > > > camera.stopPreview(); > > > > camera.release(); > > > > camera = null; > > > > } > > > > > @Override > > > > public void onClick(View v) { > > > > takePicture(); > > > > } > > > > > private void takePicture() { > > > > camera.stopPreview(); > > > > camera.takePicture(null, null, this); > > > > } > > > > > @Override > > > > public void onPictureTaken(byte[] data, Camera camera) { > > > > new SavePhotoTask().execute(data); > > > > camera.startPreview(); > > > > } > > > > > public void > > setOnPictureTakenListener(OnProfilePictureTakenListener > > > > lis) { > > > > onProfilePictureTakenListener = lis; > > > > } > > > > > class SavePhotoTask extends AsyncTask<byte[], String, String> { > > > > > @Override > > > > protected String doInBackground(byte[]... jpeg) { > > > > File photo = new > > File(Environment.getExternalStorageDirectory(), > > > > "/.addMePictures/" + System.currentTimeMillis()); > > > > if(photo.exists()) { > > > > photo.delete(); > > > > } > > > > try { > > > > FileOutputStream fos = new > > FileOutputStream(photo.getPath()); > > > > fos.write(jpeg[0]); > > > > fos.close(); > > > > } catch(IOException e) { > > > > e.printStackTrace(); > > > > } > > > > if(onProfilePictureTakenListener != null) { > > > onProfilePictureTakenListener.onProfilePictureTaken(photo); > > > > } > > > > return null; > > > > } > > > > > } > > > > > public interface OnProfilePictureTakenListener { > > > > public abstract void onProfilePictureTaken(File > > imgFile); > > > > } > > > > > } > > > > > -------- > > > > > Thank you very much! > > > > > //Kaloer > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Beginners" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected]<android-beginners%[email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

