public final void takePicture (Camera.ShutterCallback shutter,        Camera.PictureCallback raw, Camera.PictureCallback postview,        Camera.PictureCallback jpeg)

Triggers an asynchronous image capture. The camera service will initiate a series of callbacks to the application as the image capture progresses. The shutter callback occurs after the image is captured. This can be used to trigger a sound to let the user know that image has been captured. The raw callback occurs when the raw image data is available (NOTE: the data will be null if there is no raw image callback buffer available or the raw image callback buffer is not large enough to hold the raw image). The postview callback occurs when a scaled, fully processed postview image is available (NOTE: not all hardware supports this). The jpeg callback occurs when the compressed image is available. If the application does not need a particular callback, a null can be passed instead of a callback method.

This method is only valid when preview is active (after startPreview()). Preview will be stopped after the image is taken; callers must call startPreview() again if they want to re-start preview or take more pictures. This should not be called between start() and stop(). After calling this method, you must not call startPreview() or take another picture until the JPEG callback has returned.

Code fragment in the Android Camera 4.2:

mContext.getCameraDevice.takePicture(getShutterCallback(), mRawPictureCallback,    mPostViewPictureCallback, mCameraCategory.getJpegPictureCallback());
Notice that it passes four objects as parameters, each of which wraps a callback method as defined in the Camera class:
  1. ShutterCallback, which is called immediately after the image capture is complete;
  2. RawPictureCallback, which is called as soon as uncompressed data is available;
  3. PostViewPictureCallback, as soon as a scaled postview image (i.e., the image you see after taking the picture, which you can choose to discard or save) is available;
  4. JpegPictureCallback, when compressed JPEG image data is available.

In this case, the raw and postview callbacks only contain logging data, and the Shutter callback just tells the app that it doesn’t need to auto-focus anymore. The JpegPictureCallback, however, is important.

The Jpeg callback instructs the app to leave the postview picture on the screen for a short time, and then calls the setSaveRequest() method. This method calls the setData(),setIgnoreThumbnail() and addRequest() methods which is belongs to the SaveRequest Interface implements by PhotoOperator which extends RequestOperator for storage, which simply writes the JPEG data straight to file. It also adds an entry for it to Android's MediaStore provider, which keeps a list of all images and other media on the device – that way it can be viewed in the Gallery right away.

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 无法获取'https://jcenter.bintray.com/c
  2. android 4.4 添加物理按键
  3. Android listView 中响应Button点击事件
  4. Android 收集程序崩溃日志,保存本地
  5. 笔记,atmel4android,内核
  6. android典型代码系列(五)------deviceadm
  7. Android:week 12总结 内容观察者、广播、
  8. Android中Spinner控件之键值对用法实例分
  9. android获得屏幕大小,使用sdk1.6
  10. 一些小技巧(持续更新……)