首页 新闻 会员 周边

手机端仿qq的拍照和照片预览功能,求大神指点

0
[待解决问题]

 求源码:手机端仿qq的拍照和照片预览功能,求大神指点,我已经实现了拍照功能,但是批量显示,和预览功能不知道用什么控件了,初学安卓菜鸟,求大神指点

代码如下:

/**
 * 利用照相机拍照
 * @author Administrator
 *
 */
public class CameraAcitivity extends Activity{

    SurfaceView sView;
    SurfaceHolder surfaceHolder;
    int screenWidth, screenHeight;
    // 定义系统所用的照相机
    Camera camera;
    //是否在浏览中
    boolean isPreview = false;
    private static final int TAKE_PICTURE = 1;  
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.take_pic);
        Button btn = (Button) this.findViewById(R.id.btn_take_pic);
        btn.setOnClickListener(new View.OnClickListener() {
            
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //调用摄像头拍照  
                startActivityForResult(intent, TAKE_PICTURE);  
            }
        });
    
    }

    @Override  
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
      String filename = "";  
      try {  
        if (resultCode == Activity.RESULT_OK && requestCode == TAKE_PICTURE) {  
          Bundle bundle = data.getExtras();  
          Bitmap bmp = (Bitmap)bundle.get("data");  
          filename = saveImage(bmp);  
      //此处不知道该如何展示多次拍照保存的图片 ImageView show
= (ImageView) findViewById(R.id.show); show.setImageBitmap(bmp); } } catch (Exception err) { err.printStackTrace(); Log.e("Exception", err.getLocalizedMessage()); } } public String saveImage(Bitmap bmp) throws Exception { File file = new File(buildFileName()); // file.createNewFile(); FileOutputStream oStream = new FileOutputStream(file); bmp.compress(Bitmap.CompressFormat.JPEG, 100, oStream); //100是照片质量,0-100,越大越好 oStream.flush(); oStream.close(); return file.getPath(); } public String buildFileName(){ Date now = new Date(); SimpleDateFormat formater = new SimpleDateFormat("yyMMdd_HHmmss"); String newPath = ""; newPath = newPath.replace("/mnt/sdcard", ""); String SDCARD = Environment.getExternalStorageDirectory() + "/"; String basePath = SDCARD + "dier/photo/"; File dir = new File(basePath); dir.mkdirs(); return basePath+formater.format(now) + ".jpg"; } }

布局文件take_pic.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".CameraActivity" >
<RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="4dp"
        android:paddingBottom="8dp"
        android:orientation="horizontal"
    >
  <Button 
      android:id="@+id/btn_take_pic"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="takePic"
      />
  </RelativeLayout>
  <RelativeLayout 
          android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="4dp"
        android:paddingBottom="8dp"
        android:orientation="horizontal">
       <ImageView
        android:id="@+id/show"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"/>
</RelativeLayout>
</RelativeLayout>
泡泡和小九的主页 泡泡和小九 | 菜鸟二级 | 园豆:202
提问于:2015-08-31 17:58
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册