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. Android(安卓)学习笔记(3)—— ImageView/R
  2. 免费短信和电话服务TextFree在Android上
  3. Android模拟键盘之菜单键消失
  4. Android学习系列(14)--App调试的几个命令
  5. Android(安卓)EventBus库的使用
  6. android中相对布局入门
  7. ok6410 eclipse在线调试android程序
  8. Android(安卓)XML解析之SAX解析 简单示例
  9. android图形系统详解六:View layer
  10. Android(安卓)国内应用市场的汇总